cleanup - filter "unsafe" entries from driectory tag cloud

This commit is contained in:
zotlabs 2019-06-20 23:17:04 -07:00
parent 5e189cb14e
commit 17599db5c9
10 changed files with 219 additions and 194 deletions

View file

@ -2185,7 +2185,7 @@ class Activity {
$s['item_private'] = 1;
if (array_key_exists('directMessage',$act->obj)) {
if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) {
$s['item_private'] = 2;
}

View file

@ -429,12 +429,12 @@ class Calendar extends Controller {
'end' => $end,
'drop' => $drop,
'allDay' => $allDay,
'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8'),
'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
'editable' => $edit ? true : false,
'item' => $rr,
'plink' => [ $rr['plink'], t('Link to source') ],
'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8'),
'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8'),
'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8',false),
'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8',false),
'allow_cid' => expand_acl($rr['allow_cid']),
'allow_gid' => expand_acl($rr['allow_gid']),
'deny_cid' => expand_acl($rr['deny_cid']),

View file

@ -25,7 +25,6 @@ class Directory extends Controller {
);
Libsync::build_sync_packet(local_channel(), [ 'xign' => [ [ 'uid' => local_channel(), 'xchan' => $_GET['ignore'] ]]] );
goaway(z_root() . '/directory?f=&suggest=1');
}
@ -34,8 +33,6 @@ class Directory extends Controller {
$safe_changed = false;
$type_changed = false;
if (array_key_exists('global',$_REQUEST)) {
$globaldir = intval($_REQUEST['global']);
if (get_config('system','localdir_hide')) {
@ -45,9 +42,10 @@ class Directory extends Controller {
}
if ($global_changed) {
$_SESSION['globaldir'] = $globaldir;
if($observer)
if ($observer) {
set_xconfig($observer,'directory','globaldir',$globaldir);
}
}
if (array_key_exists('safe',$_REQUEST)) {
$safemode = intval($_REQUEST['safe']);
@ -55,10 +53,10 @@ class Directory extends Controller {
}
if ($safe_changed) {
$_SESSION['safemode'] = $safemode;
if($observer)
if ($observer) {
set_xconfig($observer,'directory','safemode',$safemode);
}
}
if (array_key_exists('type',$_REQUEST)) {
$type = intval($_REQUEST['type']);
@ -66,10 +64,11 @@ class Directory extends Controller {
}
if ($type_changed) {
$_SESSION['chantype'] = $type;
if($observer)
if ($observer) {
set_xconfig($observer,'directory','chantype',$type);
}
}
}
function get() {
@ -78,18 +77,19 @@ class Directory extends Controller {
return;
}
if(get_config('system','block_public_directory',false) && (! get_observer_hash())) {
$observer = get_observer_hash();
if (get_config('system','block_public_directory',false) && (! $observer)) {
notice( t('Public access denied.') . EOL);
return;
}
$observer = get_observer_hash();
$globaldir = Libzotdir::get_directory_setting($observer, 'globaldir');
// override your personal global search pref if we're doing a navbar search of the directory
if(intval($_REQUEST['navsearch']))
if (intval($_REQUEST['navsearch'])) {
$globaldir = 1;
}
$safe_mode = Libzotdir::get_directory_setting($observer, 'safemode');
@ -98,14 +98,16 @@ class Directory extends Controller {
$o = '';
nav_set_selected('Directory');
if(x($_POST,'search'))
if (x($_POST,'search')) {
$search = notags(trim($_POST['search']));
else
}
else {
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
}
if(strpos($search,'=') && local_channel() && feature_enabled(local_channel(), 'advanced_dirsearch'))
if (strpos($search,'=')) {
$advanced = $search;
}
$keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
@ -120,7 +122,6 @@ class Directory extends Controller {
$safe_mode = 1;
$type = 0;
// only return DIRECTORY_PAGESIZE suggestions as the suggestion sorting
// only works if the suggestion query and the directory query have the
// same number of results
@ -173,7 +174,6 @@ class Directory extends Controller {
$token = get_config('system','realm_token');
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
$contacts = array();
@ -183,10 +183,11 @@ class Directory extends Controller {
intval(local_channel())
);
if ($x) {
foreach($x as $xx)
foreach ($x as $xx) {
$contacts[] = $xx['abook_xchan'];
}
}
}
if ($url) {
@ -194,39 +195,48 @@ class Directory extends Controller {
$kw = ((intval($numtags) > 0) ? intval($numtags) : 50);
if(get_config('system','disable_directory_keywords'))
if (get_config('system','disable_directory_keywords')) {
$kw = 0;
}
$query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
if($token)
if ($token) {
$query .= '&t=' . $token;
}
if(! $globaldir)
if (! $globaldir) {
$query .= '&hub=' . App::get_hostname();
if($search)
}
if ($search) {
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
if(strpos($search,'@'))
}
if (strpos($search,'@')) {
$query .= '&address=' . urlencode($search);
if($keywords)
}
if ($keywords) {
$query .= '&keywords=' . urlencode($keywords);
if($advanced)
}
if ($advanced) {
$query .= '&query=' . urlencode($advanced);
if(! is_null($type))
}
if (! is_null($type)) {
$query .= '&type=' . intval($type);
}
$directory_sort_order = get_config('system','directory_sort_order');
if(! $directory_sort_order)
if (! $directory_sort_order) {
$directory_sort_order = 'date';
}
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : $directory_sort_order);
if($sort_order)
if ($sort_order) {
$query .= '&order=' . urlencode($sort_order);
}
if(App::$pager['page'] != 1)
if (App::$pager['page'] != 1) {
$query .= '&p=' . App::$pager['page'];
}
logger('mod_directory: query: ' . $query);
@ -261,54 +271,52 @@ class Directory extends Controller {
//$online = remote_online_status($rr['address']);
$online = '';
if(in_array($rr['hash'],$contacts))
if (in_array($rr['hash'],$contacts)) {
$connect_link = '';
}
$location = '';
if(strlen($rr['locale']))
if (strlen($rr['locale'])) {
$location .= $rr['locale'];
}
if (strlen($rr['region'])) {
if(strlen($rr['locale']))
if (strlen($rr['locale'])) {
$location .= ', ';
}
$location .= $rr['region'];
}
if (strlen($rr['country'])) {
if(strlen($location))
if (strlen($location)) {
$location .= ', ';
}
$location .= $rr['country'];
}
$age = '';
if (strlen($rr['birthday'])) {
if(($years = age($rr['birthday'],'UTC','')) > 0)
if (($years = age($rr['birthday'],'UTC','')) > 0) {
$age = $years;
}
}
$page_type = '';
$rating_enabled = get_config('system','rating_enabled');
if($rr['total_ratings'] && $rating_enabled)
if ($rr['total_ratings'] && $rating_enabled) {
$total_ratings = sprintf( tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']);
else
}
else {
$total_ratings = '';
}
$profile = $rr;
if ((x($profile,'locale') == 1)
|| (x($profile,'region') == 1)
|| (x($profile,'postcode') == 1)
|| (x($profile,'country') == 1))
$gender = ((x($profile,'gender') == 1) ? t('Gender: ') . $profile['gender']: False);
$marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False);
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False);
$homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
$hometown = ((x($profile,'hometown') == 1) ? html2plain($profile['hometown']) : False);
$about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'])) : False);
if ($about && $safe_mode) {
$about = html2plain($about);
@ -316,7 +324,6 @@ class Directory extends Controller {
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
$out = '';
if ($keywords) {
@ -336,18 +343,20 @@ class Directory extends Controller {
}
}
foreach ($karr as $k) {
if(strlen($out))
if (strlen($out)) {
$out .= ', ';
if($marr && in_arrayi($k,$marr))
}
if ($marr && in_arrayi($k,$marr)) {
$out .= '<a href="' . z_root() . '/directory/f=&keywords=' . urlencode($k) .'"><strong>' . $k . '</strong></a>';
else
}
else {
$out .= '<a href="' . z_root() . '/directory/f=&keywords=' . urlencode($k) .'">' . $k . '</a>';
}
}
}
}
$entry = array(
$entry = [
'id' => ++ $t,
'profile_link' => $profile_link,
'type' => $rr['type'],
@ -390,7 +399,7 @@ class Directory extends Controller {
'common_label' => t('Common connections (estimated):'),
'common_count' => intval($common[$rr['address']]),
'safe' => $safe_mode
);
];
$arr = array('contact' => $rr, 'entry' => $entry);
@ -406,7 +415,6 @@ class Directory extends Controller {
if ($sort_order == '' && $suggest) {
$entries[$addresses[$rr['address']]] = $arr['entry']; // Use the same indexes as originally to get the best suggestion first
}
else {
$entries[] = $arr['entry'];
}
@ -423,9 +431,7 @@ class Directory extends Controller {
if ($_REQUEST['aj']) {
if ($entries) {
$o = replace_macros(get_markup_template('directajax.tpl'),array(
'$entries' => $entries
));
$o = replace_macros(get_markup_template('directajax.tpl'), [ '$entries' => $entries ] );
}
else {
$o = '<div id="content-complete"></div>';
@ -439,7 +445,7 @@ class Directory extends Controller {
$dirtitle = (($globaldir) ? t('Global Directory') : t('Local Directory'));
$o .= "<script> var page_query = '" . escape_tags(urlencode($_GET['req'])) . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . "; </script>";
$o .= replace_macros($tpl, array(
$o .= replace_macros($tpl, [
'$search' => $search,
'$desc' => t('Find'),
'$finddsc' => t('Finding:'),
@ -454,11 +460,8 @@ class Directory extends Controller {
'$date' => t('Newest to Oldest'),
'$reversedate' => t('Oldest to Newest'),
'$suggest' => $suggest ? '&suggest=1' : ''
));
]);
}
}
else {
if ($_REQUEST['aj']) {
@ -466,7 +469,7 @@ class Directory extends 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);
@ -479,11 +482,9 @@ class Directory extends Controller {
static public function reorder_results($results,$suggests) {
// return $results;
if(! $suggests)
if (! $suggests) {
return $results;
}
$out = [];
foreach ($suggests as $k => $v) {
@ -494,7 +495,6 @@ class Directory extends Controller {
}
}
}
return $out;
}

View file

@ -353,7 +353,7 @@ class Dirsearch extends Controller {
$ret['results'] = $entries;
if ($kw) {
$k = dir_tagadelic($kw, $hub, $type);
$k = dir_tagadelic($kw, $hub, $type,$safesql);
if ($k) {
$ret['keywords'] = array();
foreach ($k as $kv) {

View file

@ -1,19 +1,23 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\PermissionDescription;
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
class Hq extends \Zotlabs\Web\Controller {
class Hq extends Controller {
function init() {
if(! local_channel())
return;
\App::$profile_uid = local_channel();
App::$profile_uid = local_channel();
}
function post() {
@ -104,7 +108,7 @@ class Hq extends \Zotlabs\Web\Controller {
}
if(! $update) {
$channel = \App::get_channel();
$channel = App::get_channel();
$channel_acl = [
'allow_cid' => $channel['channel_allow_cid'],
@ -119,7 +123,7 @@ class Hq extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'acl' => populate_acl($channel_acl,true, PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'permissions' => $channel_acl,
'bang' => '',
'visitor' => true,
@ -165,7 +169,7 @@ class Hq extends \Zotlabs\Web\Controller {
$o .= "<script> var profile_uid = " . local_channel()
. "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . ";</script>\r\n";
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
'$baseurl' => z_root(),
'$pgtype' => 'hq',
'$uid' => local_channel(),

View file

@ -1,11 +1,15 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\PermissionDescription;
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
class Pubstream extends \Zotlabs\Web\Controller {
class Pubstream extends Controller {
function get($update = 0, $load = false) {
@ -51,7 +55,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
if(local_channel() && (! $update)) {
$channel = \App::get_channel();
$channel = App::get_channel();
$channel_acl = array(
'allow_cid' => $channel['channel_allow_cid'],
@ -66,7 +70,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'acl' => populate_acl($channel_acl,true,PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'permissions' => $channel_acl,
'bang' => '',
'visitor' => true,
@ -105,14 +109,14 @@ class Pubstream extends \Zotlabs\Web\Controller {
$o .= '<div id="live-pubstream"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
. "; var profile_page = " . \App::$pager['page']
. "; var profile_page = " . App::$pager['page']
. "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
//if we got a decoded hash we must encode it again before handing to javascript
if($decoded)
$mid = 'b64.' . base64url_encode($mid);
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'pubstream',
'$uid' => ((local_channel()) ? local_channel() : '0'),
@ -130,7 +134,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'$wall' => '0',
'$list' => '0',
'$static' => $static,
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
'$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => '',
'$xchan' => '',
'$order' => 'comment',
@ -150,8 +154,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
$pager_sql = '';
}
else {
\App::set_pager_itemspage(20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
App::set_pager_itemspage(20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
}
require_once('include/channel.php');
@ -164,7 +168,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$sql_extra = item_permissions_sql($sys['channel_id']);
\App::$data['firehose'] = intval($sys['channel_id']);
App::$data['firehose'] = intval($sys['channel_id']);
}
if(get_config('system','public_list_mode'))
@ -180,7 +184,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
$net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
$net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : '');
$abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
$abook_uids = " and abook.abook_channel = " . intval(App::$profile['profile_uid']) . " ";
$simple_update = (($_SESSION['loadtime']) ? " AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' " : '');

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Thumbs;
use \ID3Parser\ID3Parser;
use ID3Parser\ID3Parser;
class Mp3audio {

View file

@ -2,6 +2,9 @@
namespace Zotlabs\Widget;
use App;
class Activity_filter {
function widget($arr) {
@ -9,11 +12,23 @@ class Activity_filter {
if(! local_channel())
return '';
$cmd = \App::$cmd;
$cmd = App::$cmd;
$filter_active = false;
$tabs = [];
if(x($_GET,'dm')) {
$dm_active = (($_GET['dm'] == 1) ? 'active' : '');
$filter_active = 'dm';
}
$tabs[] = [
'label' => t('Direct Messages'),
'icon' => 'envelope-o',
'url' => z_root() . '/' . $cmd . '/?dm=1',
'sel' => $dm_active,
'title' => t('Show direct (private) messages')
];
if(x($_GET,'conv')) {
$conv_active = (($_GET['conv'] == 1) ? 'active' : '');
@ -28,6 +43,7 @@ class Activity_filter {
'title' => t('Show posts that mention or involve me')
];
if(x($_GET,'verb')) {
$verb_active = (($_GET['verb'] == 1) ? 'active' : '');
$filter_active = 'events';
@ -41,6 +57,7 @@ class Activity_filter {
'title' => t('Show posts that include events')
];
if(feature_enabled(local_channel(),'star_posts')) {
if(x($_GET,'star')) {
$starred_active = (($_GET['star'] == 1) ? 'active' : '');

View file

@ -258,7 +258,7 @@ function oembed_fetch_url($embedurl){
$j['html'] = purify_html($j['html'],$allow_position);
if($j['html'] != $orig) {
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j['html'], LOGGER_DEBUG, LOG_INFO);
// logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j['html'], LOGGER_DEBUG, LOG_INFO);
}
$orig_len = mb_strlen(preg_replace('/\s+/','',$orig));

View file

@ -376,7 +376,7 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
}
function dir_tagadelic($count = 0, $hub = '', $type = 0) {
function dir_tagadelic($count = 0, $hub = '', $type = 0, $safe = '') {
$count = intval($count);
@ -397,8 +397,8 @@ function dir_tagadelic($count = 0, $hub = '', $type = 0) {
);
}
else {
$r = q("select xtag_term as term, count(xtag_term) as total from xtag where xtag_flags = 0
$sql_extra
$r = q("select xtag_term as term, count(xtag_term) as total from xtag left join xchan on xtag_hash = xchan_hash where xtag_flags = 0
$sql_extra $safe
group by xtag_term order by total desc %s",
((intval($count)) ? "limit $count" : '')
);