aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Admin.php2
-rw-r--r--Zotlabs/Module/Admin/Addons.php5
-rw-r--r--Zotlabs/Module/Admin/Site.php2
-rw-r--r--Zotlabs/Module/Affinity.php94
-rw-r--r--Zotlabs/Module/Appman.php6
-rw-r--r--Zotlabs/Module/Apporder.php33
-rw-r--r--Zotlabs/Module/Articles.php12
-rw-r--r--Zotlabs/Module/Cards.php16
-rw-r--r--Zotlabs/Module/Channel.php8
-rw-r--r--Zotlabs/Module/Chanview.php2
-rw-r--r--Zotlabs/Module/Connedit.php29
-rw-r--r--Zotlabs/Module/Display.php8
-rw-r--r--Zotlabs/Module/Dreport.php3
-rw-r--r--Zotlabs/Module/Embed.php22
-rw-r--r--Zotlabs/Module/Embedphotos.php122
-rw-r--r--Zotlabs/Module/Events.php4
-rw-r--r--Zotlabs/Module/Filestorage.php40
-rw-r--r--Zotlabs/Module/Group.php21
-rw-r--r--Zotlabs/Module/Id.php119
-rw-r--r--Zotlabs/Module/Import.php9
-rw-r--r--Zotlabs/Module/Item.php157
-rw-r--r--Zotlabs/Module/Like.php8
-rw-r--r--Zotlabs/Module/Linkinfo.php6
-rw-r--r--Zotlabs/Module/Mail.php4
-rw-r--r--Zotlabs/Module/Network.php13
-rw-r--r--Zotlabs/Module/New_channel.php4
-rw-r--r--Zotlabs/Module/Notes.php20
-rw-r--r--Zotlabs/Module/Oep.php11
-rw-r--r--Zotlabs/Module/Pconfig.php5
-rw-r--r--Zotlabs/Module/Photo.php89
-rw-r--r--Zotlabs/Module/Photos.php17
-rw-r--r--Zotlabs/Module/Ping.php14
-rw-r--r--Zotlabs/Module/Profiles.php28
-rw-r--r--Zotlabs/Module/Rmagic.php18
-rw-r--r--Zotlabs/Module/Settings/Featured.php34
-rw-r--r--Zotlabs/Module/Setup.php5
-rw-r--r--Zotlabs/Module/Share.php140
-rw-r--r--Zotlabs/Module/Sslify.php14
-rw-r--r--Zotlabs/Module/Viewsrc.php6
-rw-r--r--Zotlabs/Module/Wfinger.php3
-rw-r--r--Zotlabs/Module/Wiki.php4
41 files changed, 866 insertions, 291 deletions
diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php
index 8ccdaf4f5..88b84b9d2 100644
--- a/Zotlabs/Module/Admin.php
+++ b/Zotlabs/Module/Admin.php
@@ -86,7 +86,7 @@ class Admin extends \Zotlabs\Web\Controller {
// list total user accounts, expirations etc.
$accounts = array();
- $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires > '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account",
+ $r = q("SELECT COUNT(CASE WHEN account_id > 0 THEN 1 ELSE NULL END) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires > '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account",
db_utcnow(),
db_utcnow(),
dbesc(NULL_DATE),
diff --git a/Zotlabs/Module/Admin/Addons.php b/Zotlabs/Module/Admin/Addons.php
index b35922aef..b8e3e3a2e 100644
--- a/Zotlabs/Module/Admin/Addons.php
+++ b/Zotlabs/Module/Admin/Addons.php
@@ -375,6 +375,9 @@ class Addons {
if($files) {
foreach($files as $file) {
if (is_dir($file)){
+ if($file == 'addon/addon_common/')
+ continue;
+
list($tmp, $id) = array_map('trim', explode('/', $file));
$info = get_plugin_info($id);
$enabled = in_array($id,\App::$plugins);
@@ -476,4 +479,4 @@ class Addons {
return(strcmp(strtolower($a[2]['name']),strtolower($b[2]['name'])));
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 09b038729..55c8ca928 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -119,7 +119,7 @@ class Site {
del_config('system', 'admininfo');
} else {
require_once('include/text.php');
- linkify_tags($a, $admininfo, local_channel());
+ linkify_tags($admininfo, local_channel());
set_config('system', 'admininfo', $admininfo);
}
set_config('system','siteinfo',$siteinfo);
diff --git a/Zotlabs/Module/Affinity.php b/Zotlabs/Module/Affinity.php
new file mode 100644
index 000000000..f0d99f1e7
--- /dev/null
+++ b/Zotlabs/Module/Affinity.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
+
+class Affinity extends \Zotlabs\Web\Controller {
+
+ function post() {
+
+ if(! local_channel())
+ return;
+
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool'))
+ return;
+
+ check_form_security_token_redirectOnErr('affinity', 'affinity');
+
+ $cmax = intval($_POST['affinity_cmax']);
+ if($cmax < 0 || $cmax > 99)
+ $cmax = 99;
+
+ $cmin = intval($_POST['affinity_cmin']);
+ if($cmin < 0 || $cmin > 99)
+ $cmin = 0;
+
+ $lock = intval($_POST['affinity_lock']);
+
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ set_pconfig(local_channel(),'affinity','lock',$lock);
+
+ info( t('Affinity Tool settings updated.') . EOL);
+
+ Libsync::build_sync_packet();
+
+ }
+
+
+ function get() {
+
+ if(! local_channel())
+ return;
+
+ $desc = t('This app presents a slider control in your connection editor and also on your network page. The slider represents your degree of friendship (affinity) with each connection. It allows you to zoom in or out and display conversations from only your closest friends or everybody in your stream.');
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ //Do not display any associated widgets at this point
+ App::$pdl = '';
+
+ $o = '<b>' . t('Affinity Tool App') . ' (' . t('Not Installed') . '):</b><br>';
+ $o .= $desc;
+ return $o;
+ }
+
+ $text = t('The numbers below represent the minimum and maximum slider default positions for your network/stream page as a percentage.');
+
+ $content = '<div class="section-content-info-wrapper">' . $text . '</div>';
+
+ $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
+ $cmax = (($cmax) ? $cmax : 99);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
+ ));
+
+ $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
+ $cmin = (($cmin) ? $cmin : 0);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
+ ));
+
+ $lock = intval(get_pconfig(local_channel(),'affinity','lock',1));
+
+ $content .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
+ '$field' => array('affinity_lock', t('Persistent affinity levels'), $lock, t('If disabled the max and min levels will be reset to default after page reload'), ['No','Yes'])
+ ));
+
+ $tpl = get_markup_template("settings_addon.tpl");
+
+ $o = replace_macros($tpl, array(
+ '$action_url' => 'affinity',
+ '$form_security_token' => get_form_security_token("affinity"),
+ '$title' => t('Affinity Tool Settings'),
+ '$content' => $content,
+ '$baseurl' => z_root(),
+ '$submit' => t('Submit'),
+ ));
+
+ return $o;
+ }
+
+
+}
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index f50dcc2ab..39689665e 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -90,12 +90,12 @@ class Appman extends \Zotlabs\Web\Controller {
$channel = \App::get_channel();
- if(argc() > 2) {
+ if(argc() > 3) {
if(argv(2) === 'moveup') {
- Zlib\Apps::moveup(local_channel(),argv(1));
+ Zlib\Apps::moveup(local_channel(),argv(1),argv(3));
}
if(argv(2) === 'movedown') {
- Zlib\Apps::movedown(local_channel(),argv(1));
+ Zlib\Apps::movedown(local_channel(),argv(1),argv(3));
}
goaway(z_root() . '/apporder');
}
diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php
index a9f66ba69..eac1abc2d 100644
--- a/Zotlabs/Module/Apporder.php
+++ b/Zotlabs/Module/Apporder.php
@@ -17,25 +17,28 @@ class Apporder extends \Zotlabs\Web\Controller {
nav_set_selected('Order Apps');
- $syslist = array();
- $list = Zlib\Apps::app_list(local_channel(), false, ['nav_featured_app', 'nav_pinned_app']);
- if($list) {
- foreach($list as $li) {
- $syslist[] = Zlib\Apps::app_encode($li);
+ foreach( [ 'nav_featured_app', 'nav_pinned_app' ] as $l ) {
+ $syslist = [];
+ $list = Zlib\Apps::app_list(local_channel(), false, [ $l ]);
+ if($list) {
+ foreach($list as $li) {
+ $syslist[] = Zlib\Apps::app_encode($li);
+ }
}
- }
- Zlib\Apps::translate_system_apps($syslist);
+
+ Zlib\Apps::translate_system_apps($syslist);
- usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare');
+ usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare');
- $syslist = Zlib\Apps::app_order(local_channel(),$syslist);
+ $syslist = Zlib\Apps::app_order(local_channel(),$syslist, $l);
- foreach($syslist as $app) {
- if(strpos($app['categories'],'nav_pinned_app') !== false) {
- $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order');
- }
- else {
- $nav_apps[] = Zlib\Apps::app_render($app,'nav-order');
+ foreach($syslist as $app) {
+ if($l === 'nav_pinned_app') {
+ $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order');
+ }
+ elseif(strpos($app['categories'],'nav_pinned_app') === false) {
+ $nav_apps[] = Zlib\Apps::app_render($app,'nav-order');
+ }
}
}
diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php
index 58c16be45..ca132c01e 100644
--- a/Zotlabs/Module/Articles.php
+++ b/Zotlabs/Module/Articles.php
@@ -17,8 +17,16 @@ class Articles extends Controller {
if(argc() > 1)
$which = argv(1);
- else
- return;
+
+ if(! $which) {
+ if(local_channel()) {
+ $channel = App::get_channel();
+ if($channel && $channel['channel_address'])
+ $which = $channel['channel_address'];
+ } else {
+ return;
+ }
+ }
profile_load($which);
diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php
index b66de158b..3f0e93de5 100644
--- a/Zotlabs/Module/Cards.php
+++ b/Zotlabs/Module/Cards.php
@@ -10,9 +10,13 @@ require_once('include/channel.php');
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
+/**
+ * @brief Provides the Cards module.
+ *
+ */
class Cards extends Controller {
- function init() {
+ public function init() {
if(argc() > 1)
$which = argv(1);
@@ -20,14 +24,15 @@ class Cards extends Controller {
return;
profile_load($which);
-
}
/**
* {@inheritDoc}
- * @see \Zotlabs\Web\Controller::get()
+ * @see \\Zotlabs\\Web\\Controller::get()
+ *
+ * @return string Parsed HTML from template 'cards.tpl'
*/
- function get($update = 0, $load = false) {
+ public function get($update = 0, $load = false) {
if(observer_prohibited(true)) {
return login();
@@ -99,7 +104,6 @@ class Cards extends Controller {
}
-
if(perm_is_allowed($owner, $ob_hash, 'write_pages')) {
$x = [
@@ -110,7 +114,7 @@ class Cards extends Controller {
'nickname' => $channel['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => (($is_owner) ? populate_acl($channel_acl, false,
+ 'acl' => (($is_owner) ? populate_acl($channel_acl, false,
PermissionDescription::fromGlobalPermission('view_pages')) : ''),
'permissions' => $channel_acl,
'showacl' => (($is_owner) ? true : false),
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 12d87885f..5fdefd805 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -124,6 +124,11 @@ class Channel extends Controller {
$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : '');
+ if(strpos($mid,'b64.') === 0)
+ $decoded = @base64url_decode(substr($mid,4));
+ if($decoded)
+ $mid = $decoded;
+
$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']) : '');
@@ -375,6 +380,9 @@ class Channel extends Controller {
if((! $update) && (! $load)) {
+ if($decoded)
+ $mid = 'b64.' . base64url_encode($mid);
+
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php
index 779c7e646..2e653d030 100644
--- a/Zotlabs/Module/Chanview.php
+++ b/Zotlabs/Module/Chanview.php
@@ -106,7 +106,7 @@ class Chanview extends \Zotlabs\Web\Controller {
if (\App::$poi) {
$url = \App::$poi['xchan_url'];
- if(\App::$poi['xchan_network'] === 'zot') {
+ if(in_array(\App::$poi['xchan_network'], ['zot', 'zot6'])) {
$is_zot = true;
}
if(local_channel()) {
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index a9f643306..a587324df 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -101,7 +101,8 @@ class Connedit extends \Zotlabs\Web\Controller {
}
- $profile_id = $_POST['profile_assign'];
+ $profile_id = ((array_key_exists('profile_assign',$_POST)) ? $_POST['profile_assign'] : $orig_record[0]['abook_profile']);
+
if($profile_id) {
$r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND uid = %d LIMIT 1",
dbesc($profile_id),
@@ -113,18 +114,23 @@ class Connedit extends \Zotlabs\Web\Controller {
}
}
- $abook_incl = escape_tags($_POST['abook_incl']);
- $abook_excl = escape_tags($_POST['abook_excl']);
-
+ $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;
+ }
$closeness = intval($_POST['closeness']);
- if($closeness < 0)
- $closeness = 99;
+ if($closeness < 0 || $closeness > 99) {
+ $closeness = 80;
+ }
$rating = intval($_POST['rating']);
if($rating < (-10))
@@ -231,6 +237,8 @@ class Connedit extends \Zotlabs\Web\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'
@@ -702,7 +710,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$tpl = get_markup_template("abook_edit.tpl");
- if(feature_enabled(local_channel(),'affinity')) {
+ if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$sections['affinity'] = [
'label' => t('Affinity'),
@@ -733,9 +741,12 @@ class Connedit extends \Zotlabs\Web\Controller {
}
$slider_tpl = get_markup_template('contact_slider.tpl');
+
+ $slideval = intval($contact['abook_closeness']);
+
$slide = replace_macros($slider_tpl,array(
'$min' => 1,
- '$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99),
+ '$val' => $slideval,
'$labels' => $label_str,
));
}
@@ -892,7 +903,7 @@ class Connedit extends \Zotlabs\Web\Controller {
'$inherited' => t('inherited'),
'$submit' => t('Submit'),
'$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
- '$close' => $contact['abook_closeness'],
+ '$close' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 80),
'$them' => t('Their Settings'),
'$me' => t('My Settings'),
'$perms' => $perms,
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index d1755c183..04e5f9fce 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -178,8 +178,7 @@ class Display extends \Zotlabs\Web\Controller {
$static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0);
-
-
+
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
if($update && $_SESSION['loadtime'])
@@ -314,7 +313,7 @@ class Display extends \Zotlabs\Web\Controller {
}
}
- if(! $r) {
+ if($r === null) {
// in case somebody turned off public access to sys channel content using permissions
// make that content unsearchable by ensuring the owner_xchan can't match
if(! perm_is_allowed($sysid,$observer_hash,'view_stream'))
@@ -375,8 +374,7 @@ class Display extends \Zotlabs\Web\Controller {
}
$o .= '</noscript>';
- if ($items[0]['title'])
- \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title'];
+ \App::$page['title'] = (($items[0]['title']) ? $items[0]['title'] . " - " . \App::$page['title'] : \App::$page['title']);
$o .= conversation($items, 'display', $update, 'client');
}
diff --git a/Zotlabs/Module/Dreport.php b/Zotlabs/Module/Dreport.php
index 16ae7941f..2c125b7a9 100644
--- a/Zotlabs/Module/Dreport.php
+++ b/Zotlabs/Module/Dreport.php
@@ -80,8 +80,9 @@ class Dreport extends \Zotlabs\Web\Controller {
return;
}
- $r = q("select * from dreport where dreport_xchan = '%s' and dreport_mid = '%s'",
+ $r = q("select * from dreport where (dreport_xchan = '%s' or dreport_xchan = '%s') and dreport_mid = '%s'",
dbesc($channel['channel_hash']),
+ dbesc($channel['channel_portable_id']),
dbesc($mid)
);
diff --git a/Zotlabs/Module/Embed.php b/Zotlabs/Module/Embed.php
new file mode 100644
index 000000000..77b9254dd
--- /dev/null
+++ b/Zotlabs/Module/Embed.php
@@ -0,0 +1,22 @@
+<?php
+namespace Zotlabs\Module;
+
+require_once('include/security.php');
+require_once('include/bbcode.php');
+
+
+class Embed extends \Zotlabs\Web\Controller {
+
+ function init() {
+
+ $post_id = ((argc() > 1) ? intval(argv(1)) : 0);
+
+ if(! $post_id)
+ killme();
+
+ echo '[share=' . $post_id . '][/share]';
+ killme();
+
+ }
+
+}
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index bcbb0e116..2df14c239 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -3,8 +3,10 @@
namespace Zotlabs\Module;
/**
- * @brief
+ * @brief Embedphoto endpoint.
*
+ * Provide an AJAX endpoint to fill the embedPhotoModal with folders and photos
+ * selection.
*/
class Embedphotos extends \Zotlabs\Web\Controller {
@@ -13,42 +15,42 @@ class Embedphotos extends \Zotlabs\Web\Controller {
}
/**
+ * @brief This is the POST destination for the embedphotos button.
*
- * This is the POST destination for the embedphotos button
- *
+ * @return string A JSON string.
*/
- function post() {
+ public function post() {
if (argc() > 1 && argv(1) === 'album') {
// API: /embedphotos/album
- $name = (x($_POST,'name') ? $_POST['name'] : null );
- if(!$name) {
+ $name = (x($_POST, 'name') ? $_POST['name'] : null );
+ if (!$name) {
json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
}
$album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name));
json_return_and_die(array('status' => true, 'content' => $album));
}
- if(argc() > 1 && argv(1) === 'albumlist') {
+ if (argc() > 1 && argv(1) === 'albumlist') {
// API: /embedphotos/albumlist
- $album_list = $this->embedphotos_album_list($a);
+ $album_list = $this->embedphotos_album_list();
json_return_and_die(array('status' => true, 'albumlist' => $album_list));
}
- if(argc() > 1 && argv(1) === 'photolink') {
+ if (argc() > 1 && argv(1) === 'photolink') {
// API: /embedphotos/photolink
- $href = (x($_POST,'href') ? $_POST['href'] : null );
- if(!$href) {
+ $href = (x($_POST, 'href') ? $_POST['href'] : null );
+ if (!$href) {
json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
}
- $resource_id = array_pop(explode("/", $href));
+ $resource_id = array_pop(explode('/', $href));
$r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
dbesc($resource_id)
);
- if(!$r) {
+ if (!$r) {
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
}
$obj = json_decode($r[0]['obj'], true);
- if(x($obj,'body')) {
+ if (x($obj, 'body')) {
$photolink = $obj['body'];
- } elseif (x($obj,'bbcode')) {
+ } elseif (x($obj, 'bbcode')) {
$photolink = $obj['bbcode'];
} else {
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
@@ -58,48 +60,51 @@ class Embedphotos extends \Zotlabs\Web\Controller {
}
/**
- * Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
- * the input array as in widget_item()
+ * @brief Get photos from an album.
+ *
+ * @see \\Zotlabs\\Widget\\Album::widget()
*
- * @param array $args
- * @return string with HTML
+ * @param array $args associative array with
+ * * \e array \b channel
+ * * \e string \b album
+ * @return string with HTML code from 'photo_album.tpl'
*/
- function embedphotos_widget_album($args) {
-
+ protected function embedphotos_widget_album($args) {
$channel_id = 0;
- if(array_key_exists('channel', $args))
+
+ if (array_key_exists('channel', $args)) {
$channel = $args['channel'];
- $channel_id = intval($channel['channel_id']);
- if(! $channel_id)
+ $channel_id = intval($channel['channel_id']);
+ }
+ if (! $channel_id)
$channel_id = \App::$profile_uid;
- if(! $channel_id)
+ if (! $channel_id)
return '';
- $owner_uid = $channel_id;
require_once('include/security.php');
$sql_extra = permissions_sql($channel_id);
- if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage'))
+ if (! perm_is_allowed($channel_id, get_observer_hash(), 'view_storage'))
return '';
- if($args['album'])
+ if (isset($args['album']))
$album = (($args['album'] === '/') ? '' : $args['album']);
- if($args['title'])
+ if (isset($args['title']))
$title = $args['title'];
/**
- * This may return incorrect permissions if you have multiple directories of the same name.
+ * @note This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/
- if($album) {
+ if ($album) {
require_once('include/attach.php');
$x = q("select hash from attach where filename = '%s' and uid = %d limit 1",
dbesc($album),
- intval($owner_uid)
+ intval($channel_id)
);
- if($x) {
- $y = attach_can_view_folder($owner_uid,get_observer_hash(),$x[0]['hash']);
- if(! $y)
+ if ($x) {
+ $y = attach_can_view_folder($channel_id, get_observer_hash(), $x[0]['hash']);
+ if (! $y)
return '';
}
}
@@ -110,30 +115,33 @@ class Embedphotos extends \Zotlabs\Web\Controller {
(SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
ORDER BY created $order",
- intval($owner_uid),
+ intval($channel_id),
dbesc($album),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
);
- $photos = array();
- if(count($r)) {
+ $photos = [];
+ if (count($r)) {
$twist = 'rotright';
- foreach($r as $rr) {
- if($twist == 'rotright')
+ foreach ($r as $rr) {
+ if ($twist == 'rotright')
$twist = 'rotleft';
else
$twist = 'rotright';
+ $ph = photo_factory('');
+ $phototypes = $ph->supportedTypes();
+
$ext = $phototypes[$rr['mimetype']];
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
- $imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ $imagelink = (z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
- $photos[] = array(
+ $photos[] = [
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
'link' => $imagelink,
@@ -143,35 +151,43 @@ class Embedphotos extends \Zotlabs\Web\Controller {
'desc'=> $desc_e,
'ext' => $ext,
'hash'=> $rr['resource_id'],
- 'unknown' => t('Unknown')
- );
+ 'unknown' => t('Unknown'),
+ ];
}
}
$tpl = get_markup_template('photo_album.tpl');
- $o .= replace_macros($tpl, array(
+ $o = replace_macros($tpl, [
'$photos' => $photos,
'$album' => (($title) ? $title : $album),
'$album_id' => rand(),
- '$album_edit' => array(t('Edit Album'), $album_edit),
+ '$album_edit' => array(t('Edit Album'), false),
'$can_post' => false,
'$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$profile['channel_address'] . '/upload/' . bin2hex($album)),
'$order' => false,
- '$upload_form' => $upload_form,
- '$no_fullscreen_btn' => true
- ));
+ '$upload_form' => '',
+ '$no_fullscreen_btn' => true,
+ ]);
return $o;
}
- function embedphotos_album_list($a) {
+ /**
+ * @brief Get albums observer is allowed to see.
+ *
+ * @see photos_albums_list()
+ *
+ * @return NULL|array
+ */
+ protected function embedphotos_album_list() {
require_once('include/photos.php');
$p = photos_albums_list(\App::get_channel(), \App::get_observer());
- if($p['success']) {
+
+ if ($p['success']) {
return $p['albums'];
- } else {
- return null;
}
+
+ return null;
}
}
diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php
index 7e5204e62..e883db49f 100644
--- a/Zotlabs/Module/Events.php
+++ b/Zotlabs/Module/Events.php
@@ -97,8 +97,8 @@ class Events extends \Zotlabs\Web\Controller {
$type = escape_tags(trim($_POST['type']));
require_once('include/text.php');
- linkify_tags($a, $desc, local_channel());
- linkify_tags($a, $location, local_channel());
+ linkify_tags($desc, local_channel());
+ linkify_tags($location, local_channel());
//$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php
index 23bd63f95..2c247cd65 100644
--- a/Zotlabs/Module/Filestorage.php
+++ b/Zotlabs/Module/Filestorage.php
@@ -5,6 +5,8 @@ namespace Zotlabs\Module;
*
*/
+
+
class Filestorage extends \Zotlabs\Web\Controller {
function post() {
@@ -71,14 +73,6 @@ class Filestorage extends \Zotlabs\Web\Controller {
return;
}
- // Since we have ACL'd files in the wild, but don't have ACL here yet, we
- // need to return for anyone other than the owner, despite the perms check for now.
-
- $is_owner = (((local_channel()) && ($owner == local_channel())) ? true : false);
- if(! ($is_owner || is_site_admin())){
- info( t('Permission Denied.') . EOL );
- return;
- }
if(argc() > 3 && argv(3) === 'delete') {
@@ -101,18 +95,31 @@ class Filestorage extends \Zotlabs\Web\Controller {
}
$file = intval(argv(2));
- $r = q("SELECT hash FROM attach WHERE id = %d AND uid = %d LIMIT 1",
+ $r = q("SELECT hash, creator FROM attach WHERE id = %d AND uid = %d LIMIT 1",
dbesc($file),
intval($owner)
);
if(! $r) {
+ notice( t('File not found.') . EOL);
+
if($json_return)
json_return_and_die([ 'success' => false ]);
- notice( t('File not found.') . EOL);
goaway(z_root() . '/cloud/' . $which);
}
+ if(local_channel() !== $owner) {
+ if($r[0]['creator'] && $r[0]['creator'] !== $ob_hash) {
+ notice( t('Permission denied.') . EOL);
+
+ if($json_return)
+ json_return_and_die([ 'success' => false ]);
+
+ goaway(z_root() . '/cloud/' . $which);
+ }
+ }
+
+
$f = $r[0];
$channel = channelx_by_n($owner);
@@ -134,6 +141,19 @@ class Filestorage extends \Zotlabs\Web\Controller {
goaway(dirname($url));
}
+
+
+
+ // Since we have ACL'd files in the wild, but don't have ACL here yet, we
+ // need to return for anyone other than the owner, despite the perms check for now.
+
+ $is_owner = (((local_channel()) && ($owner == local_channel())) ? true : false);
+ if(! ($is_owner || is_site_admin())){
+ info( t('Permission Denied.') . EOL );
+ return;
+ }
+
+
if(argc() > 3 && argv(3) === 'edit') {
require_once('include/acl_selectors.php');
if(! $perms['write_storage']) {
diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php
index c8ccaa2cb..12edf8428 100644
--- a/Zotlabs/Module/Group.php
+++ b/Zotlabs/Module/Group.php
@@ -66,6 +66,9 @@ class Group extends Controller {
$groupname = notags(trim($_POST['groupname']));
$public = intval($_POST['public']);
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
+ call_hooks ('privacygroup_extras_post',$hookinfo);
+
if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) {
$r = q("UPDATE pgrp SET gname = '%s', visible = %d WHERE uid = %d AND id = %d",
dbesc($groupname),
@@ -75,6 +78,8 @@ class Group extends Controller {
);
if($r)
info( t('Privacy group updated.') . EOL );
+
+
build_sync_packet(local_channel(),null,true);
}
@@ -127,6 +132,10 @@ class Group extends Controller {
$i++;
}
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>argv(1) ];
+ call_hooks ('privacygroup_extras',$hookinfo);
+ $pgrp_extras = $hookinfo['pgrp_extras'];
+
$tpl = get_markup_template('privacy_groups.tpl');
$o = replace_macros($tpl, [
'$title' => t('Privacy Groups'),
@@ -136,6 +145,7 @@ class Group extends Controller {
// new group form
'$gname' => array('groupname',t('Privacy group name')),
'$public' => array('public',t('Members are visible to other channels'), false),
+ '$pgrp_extras' => $pgrp_extras,
'$form_security_token' => get_form_security_token("group_edit"),
'$submit' => t('Submit'),
@@ -166,8 +176,11 @@ class Group extends Controller {
);
if($r)
$result = group_rmv(local_channel(),$r[0]['gname']);
- if($result)
+ if($result) {
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>$argv(2) ];
+ call_hooks ('privacygroup_extras_drop',$hookinfo);
info( t('Privacy group removed.') . EOL);
+ }
else
notice( t('Unable to remove privacy group.') . EOL);
}
@@ -230,6 +243,10 @@ class Group extends Controller {
}
}
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
+ call_hooks ('privacygroup_extras',$hookinfo);
+ $pgrp_extras = $hookinfo['pgrp_extras'];
+
$context = $context + array(
'$title' => sprintf(t('Privacy Group: %s'), $group['gname']),
'$details_label' => t('Edit'),
@@ -240,6 +257,7 @@ class Group extends Controller {
'$form_security_token_edit' => get_form_security_token('group_edit'),
'$delete' => t('Delete Group'),
'$form_security_token_drop' => get_form_security_token("group_drop"),
+ '$pgrp_extras' => $pgrp_extras,
);
}
@@ -283,6 +301,7 @@ class Group extends Controller {
$context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click a channel to toggle membership');
+ $context['$pgrp_extras'] = $pgrp_extras;
if($change) {
$tpl = get_markup_template('groupeditor.tpl');
diff --git a/Zotlabs/Module/Id.php b/Zotlabs/Module/Id.php
new file mode 100644
index 000000000..15abfa2a3
--- /dev/null
+++ b/Zotlabs/Module/Id.php
@@ -0,0 +1,119 @@
+<?php
+
+namespace Zotlabs\Module;
+
+/**
+ *
+ * Controller for responding to x-zot: protocol requests
+ * x-zot:_jkfRG85nJ-714zn-LW_VbTFW8jSjGAhAydOcJzHxqHkvEHWG2E0RbA_pbch-h4R63RG1YJZifaNzgccoLa3MQ/453c1678-1a79-4af7-ab65-6b012f6cab77
+ *
+ */
+
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\Controller;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\ThreadListener;
+use Zotlabs\Lib\IConfig;
+use Zotlabs\Lib\Enotify;
+use App;
+
+require_once('include/attach.php');
+require_once('include/bbcode.php');
+require_once('include/security.php');
+
+
+class Id extends Controller {
+
+ function init() {
+
+ if(Libzot::is_zot_request()) {
+
+ $conversation = false;
+
+ $request_portable_id = argv(1);
+ if(argc() > 2) {
+ $item_id = argv(2);
+ }
+
+ $portable_id = EMPTY_STR;
+
+ $sigdata = HTTPSig::verify(EMPTY_STR);
+ if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $portable_id = $sigdata['portable_id'];
+ }
+
+
+ $chan = channelx_by_hash($request_portable_id);
+
+ if($chan) {
+ $channel_id = $chan['channel_id'];
+ if(! $item_id) {
+ $handler = new Channel();
+ App::$argc = 2;
+ App::$argv[0] = 'channel';
+ App::$argv[1] = $chan['channel_address'];
+ $handler->init();
+ }
+ }
+ else {
+ http_status_exit(404, 'Not found');
+ }
+
+
+ $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 uuid = '%s' $item_normal $sql_extra and uid = %d limit 1",
+ dbesc($item_id),
+ intval($channel_id)
+ );
+ if(! $r) {
+
+ $r = q("select * from item where uuid = '%s' $item_normal and uid = %d limit 1",
+ dbesc($item_id),
+ intval($channel_id)
+ );
+ if($r) {
+ http_status_exit(403, 'Forbidden');
+ }
+ http_status_exit(404, 'Not found');
+ }
+
+ if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
+ http_status_exit(403, 'Forbidden');
+
+ xchan_query($r,true);
+ $items = fetch_post_tags($r,true);
+
+ $i = Activity::encode_item($items[0]);
+
+ 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' ;
+ $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/Import.php b/Zotlabs/Module/Import.php
index 6016328a5..0daf28aa9 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -127,6 +127,15 @@ class Import extends \Zotlabs\Web\Controller {
//
// }
+
+ // prevent incompatible osada or zap data from horking your database
+
+ if(array_path_exists('compatibility/codebase',$data)) {
+ notice('Data export format is not compatible with this software');
+ return;
+ }
+
+
if($moving)
$seize = 1;
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 1d64ef60c..ebcf632ef 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -6,6 +6,13 @@ use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Enotify;
use Zotlabs\Web\Controller;
use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\ThreadListener;
+use App;
require_once('include/crypto.php');
require_once('include/items.php');
@@ -30,6 +37,144 @@ require_once('include/security.php');
class Item extends Controller {
+
+ function init() {
+
+ if(Libzot::is_zot_request()) {
+
+ $conversation = false;
+
+ $item_id = argv(1);
+
+ if(! $item_id)
+ http_status_exit(404, 'Not found');
+
+
+ $portable_id = EMPTY_STR;
+
+ $sigdata = HTTPSig::verify(EMPTY_STR);
+ if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $portable_id = $sigdata['portable_id'];
+ }
+
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
+
+ $sql_extra = item_permissions_sql(0);
+
+ $r = q("select * from item where mid = '%s' $item_normal $sql_extra limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if(! $r) {
+
+
+ $r = q("select * from item where mid = '%s' $item_normal limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if($r) {
+ http_status_exit(403, 'Forbidden');
+ }
+ http_status_exit(404, 'Not found');
+ }
+
+
+ $items = q("select parent as item_id from item where mid = '%s' and uid = %d $item_normal $sql_extra ",
+ dbesc($r[0]['parent_mid']),
+ intval($r[0]['uid'])
+ );
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+
+ $parents_str = ids_to_querystr($r,'item_id');
+
+ $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal $sql_extra ",
+ dbesc($parents_str)
+ );
+
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+ xchan_query($r,true);
+ $items = fetch_post_tags($r,true);
+
+ $observer = App::get_observer();
+ $parent = $items[0];
+ $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []);
+ $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null);
+ $nitems = [];
+ foreach($items as $i) {
+
+ $mids = [];
+
+ if(intval($i['item_private'])) {
+ if(! $observer) {
+ continue;
+ }
+ // ignore private reshare, possibly from hubzilla
+ if($i['verb'] === 'Announce') {
+ if(! in_array($i['thr_parent'],$mids)) {
+ $mids[] = $i['thr_parent'];
+ }
+ continue;
+ }
+ // also ignore any children of the private reshares
+ if(in_array($i['thr_parent'],$mids)) {
+ continue;
+ }
+
+ if((! $to) || (! in_array($observer['xchan_url'],$to))) {
+ continue;
+ }
+
+ }
+ $nitems[] = $i;
+ }
+
+ if(! $nitems)
+ http_status_exit(404, 'Not found');
+
+ $chan = channelx_by_n($nitems[0]['uid']);
+
+ if(! $chan)
+ http_status_exit(404, 'Not found');
+
+ if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
+ http_status_exit(403, 'Forbidden');
+
+ $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection',( defined('NOMADIC') ? false : true));
+ if($portable_id) {
+ ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id);
+ }
+
+ if(! $i)
+ http_status_exit(404, 'Not found');
+
+ $x = array_merge(['@context' => [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], $i);
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/x-zot+json' ;
+ $x['signature'] = LDSignatures::sign($x,$chan);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+ }
+
+
+
function post() {
// This will change. Figure out who the observer is and whether or not
@@ -553,8 +698,8 @@ class Item extends Controller {
// Look for tags and linkify them
- $results = linkify_tags($a, $summary, ($uid) ? $uid : $profile_uid);
- $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($body, ($uid) ? $uid : $profile_uid);
if($results) {
@@ -639,9 +784,9 @@ class Item extends Controller {
if(preg_match_all('/(\[share=(.*?)\](.*?)\[\/share\])/',$body,$match)) {
+
// process share by id
- $verb = ACTIVITY_SHARE;
$i = 0;
foreach($match[2] as $mtch) {
$reshare = new \Zotlabs\Lib\Share($mtch);
@@ -760,7 +905,7 @@ class Item extends Controller {
// fix permalinks for cards
if($webpage == ITEM_TYPE_CARD) {
- $plink = z_root() . '/cards/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : substr($mid,0,16));
+ $plink = z_root() . '/cards/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : $uuid);
}
if(($parent_item) && ($parent_item['item_type'] == ITEM_TYPE_CARD)) {
$r = q("select v from iconfig where iconfig.cat = 'system' and iconfig.k = 'CARD' and iconfig.iid = %d limit 1",
@@ -772,7 +917,7 @@ class Item extends Controller {
}
if($webpage == ITEM_TYPE_ARTICLE) {
- $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : substr($mid,0,16));
+ $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : $uuid);
}
if(($parent_item) && ($parent_item['item_type'] == ITEM_TYPE_ARTICLE)) {
$r = q("select v from iconfig where iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and iconfig.iid = %d limit 1",
@@ -784,7 +929,7 @@ class Item extends Controller {
}
if ((! $plink) && ($item_thread_top)) {
- $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid;
+ $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid);
$plink = substr($plink,0,190);
}
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index c39726b88..3d1f503b6 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Activity;
+
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
@@ -50,7 +52,7 @@ class Like extends \Zotlabs\Web\Controller {
$observer = \App::get_observer();
$interactive = $_REQUEST['interactive'];
- if($interactive) {
+ if((! $observer) || ($interactive)) {
$o .= '<h1>' . t('Like/Dislike') . '</h1>';
$o .= EOL . EOL;
@@ -249,6 +251,9 @@ class Like extends \Zotlabs\Web\Controller {
}
}
else {
+
+ if(! $observer)
+ killme();
// this is used to like an item or comment
@@ -400,6 +405,7 @@ class Like extends \Zotlabs\Web\Controller {
$object = json_encode(array(
'type' => $objtype,
'id' => $item['mid'],
+ 'asld' => Activity::fetch_item( [ 'id' => $item['mid'] ] ),
'parent' => (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']),
'link' => $links,
'title' => $item['title'],
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index 7c7dc0e88..32b4c0281 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -138,8 +138,8 @@ class Linkinfo extends \Zotlabs\Web\Controller {
}
$image = "";
-
- if(sizeof($siteinfo["images"]) > 0){
+
+ if(is_array($siteinfo["images"]) && count($siteinfo["images"])){
/* Execute below code only if image is present in siteinfo */
$total_images = 0;
@@ -161,7 +161,7 @@ class Linkinfo extends \Zotlabs\Web\Controller {
$total_images ++;
if($max_images && $max_images >= $total_images)
break;
- }
+ }
}
if(strlen($text)) {
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
index d38c1d88c..3202d38a5 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -34,7 +34,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
else {
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, local_channel());
+ $results = linkify_tags($body, local_channel());
if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
$attachments = array();
@@ -111,7 +111,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
require_once('include/text.php');
- linkify_tags($a, $body, local_channel());
+ linkify_tags($body, local_channel());
if(! $recipient) {
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index b93faa612..2019082ed 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Group;
+use Zotlabs\Lib\Apps;
use App;
require_once('include/items.php');
@@ -114,8 +116,8 @@ class Network extends \Zotlabs\Web\Controller {
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
+ $default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
+ $default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
@@ -132,6 +134,13 @@ class Network extends \Zotlabs\Web\Controller {
$deftag = '';
+ if (Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
+ if ($affinity_locked) {
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ }
+ }
if(x($_GET,'search') || $file || (!$pf && $cid) || $hashtags || $verb || $category || $conv || $unseen)
$nouveau = true;
diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php
index a9022a03a..98aa480fe 100644
--- a/Zotlabs/Module/New_channel.php
+++ b/Zotlabs/Module/New_channel.php
@@ -134,7 +134,7 @@ class New_channel extends \Zotlabs\Web\Controller {
$default_role = '';
$aid = get_account_id();
if($aid) {
- $r = q("select count(channel_id) as total from channel where channel_account_id = %d",
+ $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0",
intval($aid)
);
if($r && (! intval($r[0]['total']))) {
@@ -145,7 +145,7 @@ class New_channel extends \Zotlabs\Web\Controller {
$canadd = true;
if($r && ($limit !== false)) {
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
- if ($r[0]['total'] >= $limit) {
+ if ($r[0]['total'] > $limit) {
$canadd = false;
}
}
diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php
index 178a6bce0..7572f7420 100644
--- a/Zotlabs/Module/Notes.php
+++ b/Zotlabs/Module/Notes.php
@@ -1,28 +1,31 @@
<?php
-namespace Zotlabs\Module; /** @file */
+namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+/**
+ * @brief Notes Module controller.
+ */
class Notes extends Controller {
function post() {
-
+
if(! local_channel())
return EMPTY_STR;
if(! Apps::system_app_installed(local_channel(), 'Notes'))
return EMPTY_STR;
-
+
$ret = array('success' => true);
if(array_key_exists('note_text',$_REQUEST)) {
$body = escape_tags($_REQUEST['note_text']);
-
+
// I've had my notes vanish into thin air twice in four years.
- // Provide a backup copy if there were contents previously
+ // Provide a backup copy if there were contents previously
// and there are none being saved now.
-
+
if(! $body) {
$old_text = get_pconfig(local_channel(),'notes','text');
if($old_text)
@@ -40,11 +43,9 @@ class Notes extends Controller {
logger('notes saved.', LOGGER_DEBUG);
json_return_and_die($ret);
-
}
function get() {
-
if(! local_channel())
return EMPTY_STR;
@@ -61,7 +62,6 @@ class Notes extends Controller {
$arr = ['app' => true];
return $w->widget($arr);
-
}
-
+
}
diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php
index 0f20a5f9a..c0d8e15e5 100644
--- a/Zotlabs/Module/Oep.php
+++ b/Zotlabs/Module/Oep.php
@@ -181,7 +181,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -194,6 +194,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_CARD)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,6) and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
@@ -255,7 +258,6 @@ class Oep extends \Zotlabs\Web\Controller {
if(! $channel)
return $ret;
-
if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_pages'))
return $ret;
@@ -265,7 +267,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -278,6 +280,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_ARTICLE)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,7) and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
diff --git a/Zotlabs/Module/Pconfig.php b/Zotlabs/Module/Pconfig.php
index 44fe5d9a9..06b94b34f 100644
--- a/Zotlabs/Module/Pconfig.php
+++ b/Zotlabs/Module/Pconfig.php
@@ -22,6 +22,11 @@ class Pconfig extends \Zotlabs\Web\Controller {
$k = trim(escape_tags($_POST['k']));
$v = trim($_POST['v']);
$aj = intval($_POST['aj']);
+
+ // Do not store "serialized" data received in the $_POST
+ if (preg_match('|^a:[0-9]+:{.*}$|s',$v) || preg_match('|O:8:"stdClass":[0-9]+:{.*}$|s',$v)) {
+ return;
+ }
if(in_array(argv(2),$this->disallowed_pconfig())) {
notice( t('This setting requires special processing and editing has been blocked.') . EOL);
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 30e8340e2..96a4e1f40 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -1,19 +1,20 @@
<?php
+
+
namespace Zotlabs\Module;
require_once('include/security.php');
require_once('include/attach.php');
require_once('include/photo/photo_driver.php');
-
class Photo extends \Zotlabs\Web\Controller {
function init() {
- $prvcachecontrol = false;
$streaming = null;
$channel = null;
$person = 0;
+ $renew = false;
switch(argc()) {
case 4:
@@ -29,7 +30,15 @@ class Photo extends \Zotlabs\Web\Controller {
killme();
// NOTREACHED
}
-
+
+ $cache_mode = array(
+ 'on' => false,
+ 'age' => 86400,
+ 'exp' => true,
+ 'leak' => false
+ );
+ call_hooks('cache_mode_hook', $cache_mode);
+
$observer_xchan = get_observer_hash();
$ismodified = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
@@ -106,13 +115,14 @@ class Photo extends \Zotlabs\Web\Controller {
License link: http://creativecommons.org/licenses/by/3.0/
*/
+ // @FIXME It seems this part doesn't work because we are not setting such cookie
$cookie_value = false;
if (isset($_COOKIE['devicePixelRatio'])) {
$cookie_value = intval($_COOKIE['devicePixelRatio']);
}
else {
// Force revalidation of cache on next request
- $cache_directive = 'no-cache';
+ // $prvcachecontrol = 'no-cache';
$status = 'no cookie';
}
@@ -129,27 +139,42 @@ class Photo extends \Zotlabs\Web\Controller {
$resolution = 1;
}
- $r = q("SELECT uid, photo_usage FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
+ $r = q("SELECT uid, photo_usage, display_path FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
);
if($r) {
-
$allowed = (-1);
- if(intval($r[0]['photo_usage'])) {
+ $u = intval($r[0]['photo_usage']);
+ if($u) {
$allowed = 1;
- if(intval($r[0]['photo_usage']) === PHOTO_COVER)
+ if($u === PHOTO_COVER)
if($resolution < PHOTO_RES_COVER_1200)
$allowed = (-1);
- if(intval($r[0]['photo_usage']) === PHOTO_PROFILE)
+ if($u === PHOTO_PROFILE)
if(! in_array($resolution,[4,5,6]))
$allowed = (-1);
+ if($u === PHOTO_CACHE) {
+ // Validate cache
+ $cache = array(
+ 'resid' => $photo,
+ 'status' => false
+ );
+ if($cache_mode['on'])
+ call_hooks('cache_url_hook', $cache);
+ if(! $cache['status']) {
+ $url = htmlspecialchars_decode($r[0]['display_path']);
+ if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false)
+ $url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);
+ header("Location: " . $url);
+ killme();
+ }
+ }
}
- if($allowed === (-1)) {
+ if($allowed === (-1))
$allowed = attach_can_view($r[0]['uid'],$observer_xchan,$photo);
- }
$channel = channelx_by_n($r[0]['uid']);
@@ -158,18 +183,21 @@ class Photo extends \Zotlabs\Web\Controller {
dbesc($photo),
intval($resolution)
);
-
+
$exists = (($e) ? true : false);
-
+
if($exists && $allowed) {
+ $expires = strtotime($e[0]['expires'] . 'Z');
$data = dbunescbin($e[0]['content']);
$filesize = $e[0]['filesize'];
$mimetype = $e[0]['mimetype'];
$modified = strtotime($e[0]['edited'] . 'Z');
- if(intval($e[0]['os_storage']))
+
+ if(intval($e[0]['os_storage'])) {
$streaming = $data;
+ }
if($e[0]['allow_cid'] != '' || $e[0]['allow_gid'] != '' || $e[0]['deny_gid'] != '' || $e[0]['deny_gid'] != '')
- $prvcachecontrol = true;
+ $prvcachecontrol = 'no-store, no-cache, must-revalidate';
}
else {
if(! $allowed) {
@@ -180,9 +208,9 @@ class Photo extends \Zotlabs\Web\Controller {
}
}
- } else {
+ }
+ else
http_status_exit(404,'not found');
- }
}
header_remove('Pragma');
@@ -225,24 +253,14 @@ class Photo extends \Zotlabs\Web\Controller {
$mimetype = $ph->getType();
}
}
-
- // @FIXME Seems never invoked
- // Writing in cachefile
- if (isset($cachefile) && $cachefile != '') {
- file_put_contents($cachefile, $data);
- $modified = filemtime($cachefile);
- }
-
- header("Content-type: " . $mimetype);
-
- if($prvcachecontrol) {
+ if(isset($prvcachecontrol)) {
// it is a private photo that they have no permission to view.
// tell the browser not to cache it, in case they authenticate
// and subsequently have permission to see it
- header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: " . $prvcachecontrol);
}
else {
@@ -255,18 +273,23 @@ class Photo extends \Zotlabs\Web\Controller {
// This has performance considerations but we highly recommend you
// leave it alone.
- $cache = get_config('system','photo_cache_time', 86400); // 1 day by default
+ $maxage = $cache_mode['age'];
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT");
- header("Cache-Control: max-age=" . $cache);
+ if($cache_mode['exp'] || (! isset($expires)) || (isset($expires) && $expires - 60 < time()))
+ $expires = time() + $maxage;
+ else
+ $maxage = $expires - time();
+
+ header("Expires: " . gmdate("D, d M Y H:i:s", $expires) . " GMT");
+ header("Cache-Control: max-age=" . $maxage);
}
+ header("Content-type: " . $mimetype);
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT");
header("Content-Length: " . (isset($filesize) ? $filesize : strlen($data)));
// If it's a file resource, stream it.
-
if($streaming && $channel) {
if(strpos($streaming,'store') !== false)
$istream = fopen($streaming,'rb');
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 21f6293ef..a761dbd14 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -422,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller {
require_once('include/text.php');
$profile_uid = \App::$profile['profile_uid'];
- $results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
+ $results = linkify_tags($rawtags, (local_channel()) ? local_channel() : $profile_uid);
$success = $results['success'];
$post_tags = array();
@@ -988,7 +988,7 @@ class Photos extends \Zotlabs\Web\Controller {
$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']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
+ 'src' => z_root() . '/photo/' . $lores['resource_id'] . '-' . $lores['imgscale'] . '.' . $phototypes[$lores['mimetype']]
);
if($nextlink)
@@ -1122,6 +1122,7 @@ class Photos extends \Zotlabs\Web\Controller {
$comments = '';
if(! $r) {
if($observer && ($can_post || $can_comment)) {
+ $feature_auto_save_draft = ((feature_enabled($owner_uid, 'auto_save_draft')) ? "true" : "false");
$commentbox = replace_macros($cmnt_tpl,array(
'$return_path' => '',
'$mode' => 'photos',
@@ -1137,7 +1138,8 @@ class Photos extends \Zotlabs\Web\Controller {
'$submit' => t('Submit'),
'$preview' => t('Preview'),
'$ww' => '',
- '$feature_encrypt' => false
+ '$feature_encrypt' => false,
+ '$auto_save_draft' => $feature_auto_save_draft
));
}
}
@@ -1270,8 +1272,14 @@ class Photos extends \Zotlabs\Web\Controller {
if(feature_enabled($owner_uid,'dislike'))
$response_verbs[] = 'dislike';
-
$responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+
+ $hookdata = [
+ 'onclick' => '$.colorbox({href: \'' . $photo['href'] . '\'}); return false;',
+ 'raw_photo' => $ph[0],
+ '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(
@@ -1309,6 +1317,7 @@ class Photos extends \Zotlabs\Web\Controller {
'$comments' => $comments,
'$commentbox' => $commentbox,
'$paginate' => $paginate,
+ '$onclick' => $hookdata['onclick']
));
\App::$data['photo_html'] = $o;
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php
index f660c3b55..a367b1062 100644
--- a/Zotlabs/Module/Ping.php
+++ b/Zotlabs/Module/Ping.php
@@ -330,6 +330,7 @@ class Ping extends \Zotlabs\Web\Controller {
$notifs[] = array(
'notify_link' => z_root() . '/mail/' . $zz['id'],
'name' => $zz['xchan_name'],
+ 'addr' => $zz['xchan_addr'],
'url' => $zz['xchan_url'],
'photo' => $zz['xchan_photo_s'],
'when' => relative_date($zz['created']),
@@ -346,6 +347,10 @@ class Ping extends \Zotlabs\Web\Controller {
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
$result = array();
+ if(argv(1) === 'home') {
+ $sql_extra .= ' and item_wall = 1 ';
+ }
+
$r = q("SELECT * FROM item
WHERE uid = %d
AND item_unseen = 1
@@ -361,8 +366,6 @@ class Ping extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
foreach($r as $item) {
- if((argv(1) === 'home') && (! intval($item['item_wall'])))
- continue;
$result[] = \Zotlabs\Lib\Enotify::format($item);
}
}
@@ -383,6 +386,7 @@ class Ping extends \Zotlabs\Web\Controller {
$result[] = array(
'notify_link' => z_root() . '/connections/ifpending',
'name' => $rr['xchan_name'],
+ 'addr' => $rr['xchan_addr'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
'when' => relative_date($rr['abook_created']),
@@ -407,6 +411,7 @@ class Ping extends \Zotlabs\Web\Controller {
$result[] = array(
'notify_link' => z_root() . '/admin/accounts',
'name' => $rr['account_email'],
+ 'addr' => $rr['account_email'],
'url' => '',
'photo' => z_root() . '/' . get_default_profile_photo(48),
'when' => relative_date($rr['account_created']),
@@ -444,6 +449,7 @@ class Ping extends \Zotlabs\Web\Controller {
$result[] = array(
'notify_link' => z_root() . '/events', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
'name' => $rr['xchan_name'],
+ 'addr' => $rr['xchan_addr'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
'when' => $when,
@@ -460,7 +466,7 @@ class Ping extends \Zotlabs\Web\Controller {
if(argc() > 1 && (argv(1) === 'files')) {
$result = array();
- $r = q("SELECT item.created, xchan.xchan_name, xchan.xchan_url, xchan.xchan_photo_s FROM item
+ $r = q("SELECT item.created, xchan.xchan_name, xchan.xchan_addr, xchan.xchan_url, xchan.xchan_photo_s FROM item
LEFT JOIN xchan on author_xchan = xchan_hash
WHERE item.verb = '%s'
AND item.obj_type = '%s'
@@ -477,6 +483,7 @@ class Ping extends \Zotlabs\Web\Controller {
$result[] = array(
'notify_link' => z_root() . '/sharedwithme',
'name' => $rr['xchan_name'],
+ 'addr' => $rr['xchan_addr'],
'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'],
'when' => relative_date($rr['created']),
@@ -658,6 +665,7 @@ class Ping extends \Zotlabs\Web\Controller {
if($r[0]['unseen']) {
$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]['name'] = $forums[$x]['xchan_name'];
+ $forums[$x]['addr'] = $forums[$x]['xchan_addr'];
$forums[$x]['url'] = $forums[$x]['xchan_url'];
$forums[$x]['photo'] = $forums[$x]['xchan_photo_s'];
$forums[$x]['unseen'] = $r[0]['unseen'];
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index de4075ba9..33e7d8a9d 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -354,20 +354,20 @@ class Profiles extends \Zotlabs\Web\Controller {
require_once('include/text.php');
- linkify_tags($a, $likes, local_channel());
- linkify_tags($a, $dislikes, local_channel());
- linkify_tags($a, $about, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $contact, local_channel());
- linkify_tags($a, $channels, local_channel());
- linkify_tags($a, $music, local_channel());
- linkify_tags($a, $book, local_channel());
- linkify_tags($a, $tv, local_channel());
- linkify_tags($a, $film, local_channel());
- linkify_tags($a, $romance, local_channel());
- linkify_tags($a, $work, local_channel());
- linkify_tags($a, $education, local_channel());
+ linkify_tags($likes, local_channel());
+ linkify_tags($dislikes, local_channel());
+ linkify_tags($about, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($contact, local_channel());
+ linkify_tags($channels, local_channel());
+ linkify_tags($music, local_channel());
+ linkify_tags($book, local_channel());
+ linkify_tags($tv, local_channel());
+ linkify_tags($film, local_channel());
+ linkify_tags($romance, local_channel());
+ linkify_tags($work, local_channel());
+ linkify_tags($education, local_channel());
$with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : '');
diff --git a/Zotlabs/Module/Rmagic.php b/Zotlabs/Module/Rmagic.php
index 33a6689ca..8c1e5cdab 100644
--- a/Zotlabs/Module/Rmagic.php
+++ b/Zotlabs/Module/Rmagic.php
@@ -14,6 +14,15 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($me)
);
+ if(! $r) {
+ $w = discover_by_webbie($me);
+ if($w) {
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ dbesc($me)
+ );
+ }
+ }
+
if($r) {
if($r[0]['hubloc_url'] === z_root())
goaway(z_root() . '/login');
@@ -49,7 +58,16 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($address)
);
+ if(! $r) {
+ $w = discover_by_webbie($address);
+ if($w) {
+ $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
+ dbesc($address)
+ );
+ }
+ }
}
+
if($r) {
$url = $r[0]['hubloc_url'];
}
diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php
index 542a05363..d5d740aff 100644
--- a/Zotlabs/Module/Settings/Featured.php
+++ b/Zotlabs/Module/Settings/Featured.php
@@ -10,20 +10,6 @@ class Featured {
call_hooks('feature_settings_post', $_POST);
- if($_POST['affinity_slider-submit']) {
- $cmax = intval($_POST['affinity_cmax']);
- if($cmax < 0 || $cmax > 99)
- $cmax = 99;
- $cmin = intval($_POST['affinity_cmin']);
- if($cmin < 0 || $cmin > 99)
- $cmin = 0;
- set_pconfig(local_channel(),'affinity','cmin',$cmin);
- set_pconfig(local_channel(),'affinity','cmax',$cmax);
-
- info( t('Affinity Slider settings updated.') . EOL);
-
- }
-
build_sync_packet();
return;
}
@@ -37,30 +23,10 @@ class Featured {
if(! $r)
$settings_addons = t('No feature settings configured');
- if(feature_enabled(local_channel(),'affinity')) {
-
- $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
- $cmax = (($cmax) ? $cmax : 99);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
- ));
- $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
- $cmin = (($cmin) ? $cmin : 0);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
- ));
-
- $settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
- '$addon' => array('affinity_slider', '' . t('Affinity Slider Settings'), '', t('Submit')),
- '$content' => $setting_fields
- ));
- }
-
call_hooks('feature_settings', $settings_addons);
$this->sortpanels($settings_addons);
-
$tpl = get_markup_template("settings_addons.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_featured"),
diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php
index c0716ca7c..370b7b9f8 100644
--- a/Zotlabs/Module/Setup.php
+++ b/Zotlabs/Module/Setup.php
@@ -441,13 +441,18 @@ class Setup extends \Zotlabs\Web\Controller {
require_once 'include/environment.php';
$help = '';
+ $mem_warning = '';
$result = getPhpiniUploadLimits();
+ if($result['post_max_size'] < 4194304 || $result['max_upload_filesize'] < 4194304) {
+ $mem_warning = '<strong>' .t('This is not sufficient to upload larger images or files. You should be able to upload at least 4 MB at once.') . '</strong>';
+ }
$help = sprintf(t('Your max allowed total upload size is set to %s. Maximum size of one file to upload is set to %s. You are allowed to upload up to %d files at once.'),
userReadableSize($result['post_max_size']),
userReadableSize($result['max_upload_filesize']),
$result['max_file_uploads']
);
+ $help .= $mem_warning;
$help .= '<br><br>' . t('You can adjust these settings in the server php.ini file.');
$this->check_add($checks, t('PHP upload limits'), true, false, $help);
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index c6d0be051..53a06b072 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -1,6 +1,11 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+
+
require_once('include/security.php');
require_once('include/bbcode.php');
@@ -14,23 +19,23 @@ class Share extends \Zotlabs\Web\Controller {
if(! $post_id)
killme();
- echo '[share=' . $post_id . '][/share]';
- killme();
+ if(! local_channel()) {
+ killme();
+ }
+ $observer = App::get_observer();
- /**
- * The remaining code is deprecated and handled in Zotlabs/Lib/Share.php at post
- * submission time.
- */
+ $channel = App::get_channel();
- if(! (local_channel() || remote_channel()))
- killme();
-
$r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1",
intval($post_id)
);
if(! $r)
killme();
+
+
+
+
if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss'))
killme();
@@ -46,59 +51,86 @@ class Share extends \Zotlabs\Web\Controller {
if($r[0]['mimetype'] !== 'text/bbcode')
killme();
-
- /** @FIXME eventually we want to post remotely via rpost on your home site */
- // When that works remove this next bit:
-
- if(! local_channel())
- killme();
-
+
xchan_query($r);
- $is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
- if($is_photo) {
- $object = json_decode($r[0]['obj'],true);
- $photo_bb = $object['body'];
- }
-
- if (strpos($r[0]['body'], "[/share]") !== false) {
- $pos = strpos($r[0]['body'], "[share");
- $o = substr($r[0]['body'], $pos);
- } else {
- $o = "[share author='" . urlencode($r[0]['author']['xchan_name']) .
- "' profile='" . $r[0]['author']['xchan_url'] .
- "' avatar='" . $r[0]['author']['xchan_photo_s'] .
- "' link='" . $r[0]['plink'] .
- "' auth='" . (($r[0]['author']['network'] === 'zot') ? 'true' : 'false') .
- "' posted='" . $r[0]['created'] .
- "' message_id='" . $r[0]['mid'] .
- "']";
- if($r[0]['title'])
- $o .= '[b]'.$r[0]['title'].'[/b]'."\r\n";
- $o .= (($is_photo) ? $photo_bb . "\r\n" . $r[0]['body'] : $r[0]['body']);
- $o .= "[/share]";
- }
-
- if(local_channel()) {
- echo $o;
+ $arr = [];
+
+ $item = $r[0];
+
+ $owner_uid = $r[0]['uid'];
+ $owner_aid = $r[0]['aid'];
+
+ $can_comment = false;
+ if((array_key_exists('owner',$item)) && intval($item['owner']['abook_self']))
+ $can_comment = perm_is_allowed($item['uid'],$observer['xchan_hash'],'post_comments');
+ else
+ $can_comment = can_comment_on_post($observer['xchan_hash'],$item);
+
+ if(! $can_comment) {
+ notice( t('Permission denied') . EOL);
killme();
}
+
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['owner_xchan'])
+ );
+
+ if($r)
+ $thread_owner = $r[0];
+ else
+ killme();
- $observer = \App::get_observer();
- $parsed = $observer['xchan_url'];
- if($parsed) {
- $post_url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '')
- . '/rpost';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['author_xchan'])
+ );
+ if($r)
+ $item_author = $r[0];
+ else
+ killme();
- /**
- * @FIXME we were probably called from JS so we don't know the return page.
- * In fact we won't be able to load the remote page.
- * we might need an iframe
- */
+
+ $arr['aid'] = $owner_aid;
+ $arr['uid'] = $owner_uid;
+
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = $item['item_wall'];
+ $arr['uuid'] = item_message_id();
+ $arr['mid'] = z_root() . '/activity/' . $arr['uuid'];
+ $arr['parent_mid'] = $item['mid'];
+
+ $mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]';
+ $arr['body'] = sprintf( t('&#x1f501; Repeated %1$s\'s %2$s'), $mention, Activity::activity_obj_mapper($item['obj_type']));
+
+ $arr['author_xchan'] = $channel['channel_hash'];
+ $arr['owner_xchan'] = $item['author_xchan'];
+ $arr['obj'] = Activity::encode_item($item);
+ $arr['obj_type'] = $item['obj_type'];
+ $arr['verb'] = 'Announce';
+
+ $post = item_store($arr);
+
+ $post_id = $post['item_id'];
+
+ $arr['id'] = $post_id;
- $x = z_post_url($post_url, array('f' => '', 'body' => $o ));
- killme();
+ call_hooks('post_local_end', $arr);
+
+ info( t('Post repeated') . EOL);
+
+ $r = q("select * from item where id = %d",
+ intval($post_id)
+ );
+ if($r) {
+ xchan_query($r);
+ $sync_item = fetch_post_tags($r);
+ build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
}
+
+ Master::Summon([ 'Notifier','like',$post_id ]);
+
+ killme();
+
}
}
diff --git a/Zotlabs/Module/Sslify.php b/Zotlabs/Module/Sslify.php
index 2891f3691..37be4423b 100644
--- a/Zotlabs/Module/Sslify.php
+++ b/Zotlabs/Module/Sslify.php
@@ -12,10 +12,16 @@ class Sslify extends \Zotlabs\Web\Controller {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[strtolower($k)] = $v;
}
- if (array_key_exists('content-type', $hdrs)) {
- $type = $hdrs['content-type'];
- header('Content-Type: ' . $type);
- }
+
+ if (array_key_exists('content-type', $hdrs))
+ header('Content-Type: ' . $hdrs['content-type']);
+ if (array_key_exists('last-modified', $hdrs))
+ header('Last-Modified: ' . $hdrs['last-modified']);
+ if (array_key_exists('cache-control', $hdrs))
+ header('Cache-Control: ' . $hdrs['cache-control']);
+ if (array_key_exists('expires', $hdrs))
+ header('Expires: ' . $hdrs['expires']);
+
echo $x['body'];
killme();
diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php
index 119990b57..3e49b9db4 100644
--- a/Zotlabs/Module/Viewsrc.php
+++ b/Zotlabs/Module/Viewsrc.php
@@ -25,10 +25,10 @@ class Viewsrc extends \Zotlabs\Web\Controller {
notice( t('Item not found.') . EOL);
}
- $item_normal = item_normal();
+ $item_normal = item_normal_search();
if(local_channel() && $item_id) {
- $r = q("select id, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
+ $r = q("select id, mid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
@@ -53,7 +53,7 @@ class Viewsrc extends \Zotlabs\Web\Controller {
if(is_ajax()) {
echo '<div class="p-1">';
- echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a></div>';
+ echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a><br>mid: ' . $r[0]['mid'] . '</div>';
echo '<hr>';
echo '<pre class="p-1">' . $o . '</pre>';
echo '</div>';
diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php
index e4591df12..03275abbc 100644
--- a/Zotlabs/Module/Wfinger.php
+++ b/Zotlabs/Module/Wfinger.php
@@ -43,6 +43,9 @@ class Wfinger extends \Zotlabs\Web\Controller {
if(strpos($resource,'acct:') === 0) {
$channel = str_replace('acct:','',$resource);
+ if(substr($channel,0,1) === '@' && strpos(substr($channel,1),'@')) {
+ $channel = substr($channel,1);
+ }
if(strpos($channel,'@') !== false) {
$host = substr($channel,strpos($channel,'@')+1);
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 892810241..502f96a62 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -442,8 +442,8 @@ class Wiki extends Controller {
$mimeType = $_POST['mimetype'];
if($mimeType === 'text/bbcode') {
- $linkconverted = NativeWikiPage::convert_links($content,$wikiURL);
- $html = zidify_links(smilies(bbcode($linkconverted)));
+ $html = zidify_links(smilies(bbcode($content)));
+ $html = NativeWikiPage::convert_links($html,$wikiURL);
}
elseif($mimeType === 'text/markdown') {
$linkconverted = NativeWikiPage::convert_links($content,$wikiURL);