turn the oft-repeated block_public ... check into a function observer_prohibited()

This commit is contained in:
redmatrix 2016-05-22 17:52:30 -07:00
parent d7d347469c
commit 5e0698ba87
16 changed files with 342 additions and 338 deletions

View File

@ -260,7 +260,7 @@ class Acl extends \Zotlabs\Web\Controller {
// logger('navbar_complete');
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}

View File

@ -11,7 +11,7 @@ require_once('include/items.php');
class Cal extends \Zotlabs\Web\Controller {
function init() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}
@ -47,11 +47,10 @@ class Cal extends \Zotlabs\Web\Controller {
function get() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}
$channel = null;
if(argc() > 1) {

View File

@ -67,7 +67,7 @@ function get($update = 0, $load = false) {
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
if(observer_prohibited(true)) {
return login();
}
@ -180,7 +180,8 @@ function get($update = 0, $load = false) {
dbesc($mid . '%'),
intval(\App::$profile['profile_uid'])
);
} else {
}
else {
$r = q("SELECT distinct parent AS `item_id`, created from item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
WHERE uid = %d $item_normal
@ -225,7 +226,8 @@ function get($update = 0, $load = false) {
notice( t('Permission denied.') . EOL);
}
} else {
}
else {
$r = q("SELECT distinct id AS item_id, created FROM item
left join abook on item.author_xchan = abook.abook_xchan
WHERE uid = %d $item_normal
@ -265,7 +267,8 @@ function get($update = 0, $load = false) {
notice( t('Permission denied.') . EOL);
}
} else {
}
else {
$items = array();
}
@ -345,7 +348,8 @@ function get($update = 0, $load = false) {
if($checkjs->disabled()) {
$o .= conversation($a,$items,'channel',$update,'traditional');
} else {
}
else {
$o .= conversation($a,$items,'channel',$update,$page_mode);
}
@ -360,6 +364,4 @@ function get($update = 0, $load = false) {
return $o;
}
}

View File

@ -59,7 +59,7 @@ class Directory extends \Zotlabs\Web\Controller {
function get() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}

View File

@ -7,17 +7,13 @@ class Display extends \Zotlabs\Web\Controller {
function get($update = 0, $load = false) {
// logger("mod-display: update = $update load = $load");
$checkjs = new \Zotlabs\Web\CheckJS(1);
if($load)
$_SESSION['loadtime'] = datetime_convert();
if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}

View File

@ -31,7 +31,7 @@ class Feed extends \Zotlabs\Web\Controller {
$channel = $r[0];
if((intval(get_config('system','block_public'))) && (! get_account_id()))
if(observer_prohibited(true))
killme();
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);

View File

@ -18,7 +18,7 @@ class Photos extends \Zotlabs\Web\Controller {
function init() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}
@ -518,7 +518,7 @@ class Photos extends \Zotlabs\Web\Controller {
// photos/name/image/xxxxx
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}

View File

@ -55,7 +55,7 @@ class Profile extends \Zotlabs\Web\Controller {
function get() {
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
if(observer_prohibited(true)) {
return login();
}

View File

@ -12,7 +12,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
$_SESSION['loadtime'] = datetime_convert();
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
if(observer_prohibited(true)) {
return login();
}

View File

@ -8,7 +8,7 @@ class Ratings extends \Zotlabs\Web\Controller {
function init() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}
@ -82,7 +82,7 @@ class Ratings extends \Zotlabs\Web\Controller {
function get() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}

View File

@ -7,7 +7,7 @@ class Viewconnections extends \Zotlabs\Web\Controller {
function init() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
return;
}
if(argc() > 1)
@ -16,7 +16,7 @@ class Viewconnections extends \Zotlabs\Web\Controller {
function get() {
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}

View File

@ -15,7 +15,7 @@ class Zotfeed extends \Zotlabs\Web\Controller {
if(! $mindate)
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
if(observer_prohibited()) {
$result['message'] = 'Public access denied';
json_return_and_die($result);
}
@ -45,8 +45,6 @@ class Zotfeed extends \Zotlabs\Web\Controller {
$result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],array('mindate' => $mindate));
$result['success'] = true;
json_return_and_die($result);
}
}

View File

@ -2400,3 +2400,12 @@ function check_cron_broken() {
}
function observer_prohibited($allow_account = false) {
if($allow_account)
return (((get_config('system','block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false );
return (((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) ? true : false );
}

View File

@ -1567,7 +1567,7 @@ function get_online_status($nick) {
$ret = array('result' => false);
if(get_config('system','block_public') && ! local_channel() && ! remote_channel())
if(observer_prohibited())
return $ret;
$r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1",

View File

@ -402,7 +402,7 @@ function poco($a,$extended = false) {
$system_mode = false;
if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
if(observer_prohibited()) {
logger('mod_poco: block_public');
http_status_exit(401);
}

View File

@ -12,13 +12,13 @@ require_once('include/attach.php');
function widget_profile($args) {
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
$block = observer_prohibited();
return profile_sidebar(App::$profile, $block, true);
}
function widget_zcard($args) {
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
$block = observer_prohibited();
$channel = channelx_by_n(App::$profile_uid);
return get_zcard($channel,get_observer_hash(),array('width' => 875));
}
@ -369,7 +369,7 @@ function widget_fullprofile($arr) {
if(! App::$profile['profile_uid'])
return;
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
$block = observer_prohibited();
return profile_sidebar(App::$profile, $block);
}
@ -379,7 +379,7 @@ function widget_shortprofile($arr) {
if(! App::$profile['profile_uid'])
return;
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
$block = observer_prohibited();
return profile_sidebar(App::$profile, $block, true, true);
}