turn the oft-repeated block_public ... check into a function observer_prohibited()
This commit is contained in:
parent
d7d347469c
commit
5e0698ba87
@ -260,7 +260,7 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
// logger('navbar_complete');
|
// logger('navbar_complete');
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ require_once('include/items.php');
|
|||||||
class Cal extends \Zotlabs\Web\Controller {
|
class Cal extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,11 +47,10 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$channel = null;
|
$channel = null;
|
||||||
|
|
||||||
if(argc() > 1) {
|
if(argc() > 1) {
|
||||||
|
@ -67,7 +67,7 @@ function get($update = 0, $load = false) {
|
|||||||
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
|
$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']) : '');
|
$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();
|
return login();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,8 @@ function get($update = 0, $load = false) {
|
|||||||
dbesc($mid . '%'),
|
dbesc($mid . '%'),
|
||||||
intval(\App::$profile['profile_uid'])
|
intval(\App::$profile['profile_uid'])
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$r = q("SELECT distinct parent AS `item_id`, created from item
|
$r = q("SELECT distinct parent AS `item_id`, created from item
|
||||||
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
|
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
|
||||||
WHERE uid = %d $item_normal
|
WHERE uid = %d $item_normal
|
||||||
@ -225,7 +226,8 @@ function get($update = 0, $load = false) {
|
|||||||
notice( t('Permission denied.') . EOL);
|
notice( t('Permission denied.') . EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$r = q("SELECT distinct id AS item_id, created FROM item
|
$r = q("SELECT distinct id AS item_id, created FROM item
|
||||||
left join abook on item.author_xchan = abook.abook_xchan
|
left join abook on item.author_xchan = abook.abook_xchan
|
||||||
WHERE uid = %d $item_normal
|
WHERE uid = %d $item_normal
|
||||||
@ -265,7 +267,8 @@ function get($update = 0, $load = false) {
|
|||||||
notice( t('Permission denied.') . EOL);
|
notice( t('Permission denied.') . EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$items = array();
|
$items = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +348,8 @@ function get($update = 0, $load = false) {
|
|||||||
|
|
||||||
if($checkjs->disabled()) {
|
if($checkjs->disabled()) {
|
||||||
$o .= conversation($a,$items,'channel',$update,'traditional');
|
$o .= conversation($a,$items,'channel',$update,'traditional');
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$o .= conversation($a,$items,'channel',$update,$page_mode);
|
$o .= conversation($a,$items,'channel',$update,$page_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,6 +364,4 @@ function get($update = 0, $load = false) {
|
|||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -59,7 +59,7 @@ class Directory extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
notice( t('Public access denied.') . EOL);
|
notice( t('Public access denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,13 @@ class Display extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get($update = 0, $load = false) {
|
function get($update = 0, $load = false) {
|
||||||
|
|
||||||
// logger("mod-display: update = $update load = $load");
|
|
||||||
|
|
||||||
|
|
||||||
$checkjs = new \Zotlabs\Web\CheckJS(1);
|
$checkjs = new \Zotlabs\Web\CheckJS(1);
|
||||||
|
|
||||||
|
|
||||||
if($load)
|
if($load)
|
||||||
$_SESSION['loadtime'] = datetime_convert();
|
$_SESSION['loadtime'] = datetime_convert();
|
||||||
|
|
||||||
|
|
||||||
if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
notice( t('Public access denied.') . EOL);
|
notice( t('Public access denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class Feed extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$channel = $r[0];
|
$channel = $r[0];
|
||||||
|
|
||||||
if((intval(get_config('system','block_public'))) && (! get_account_id()))
|
if(observer_prohibited(true))
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
|
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
|
||||||
|
@ -18,7 +18,7 @@ class Photos extends \Zotlabs\Web\Controller {
|
|||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ class Photos extends \Zotlabs\Web\Controller {
|
|||||||
// photos/name/image/xxxxx
|
// photos/name/image/xxxxx
|
||||||
|
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
notice( t('Public access denied.') . EOL);
|
notice( t('Public access denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ class Profile extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
|
if(observer_prohibited(true)) {
|
||||||
return login();
|
return login();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
|||||||
$_SESSION['loadtime'] = datetime_convert();
|
$_SESSION['loadtime'] = datetime_convert();
|
||||||
|
|
||||||
|
|
||||||
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
|
if(observer_prohibited(true)) {
|
||||||
return login();
|
return login();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class Ratings extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class Ratings extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
notice( t('Public access denied.') . EOL);
|
notice( t('Public access denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ class Viewconnections extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(argc() > 1)
|
if(argc() > 1)
|
||||||
@ -16,7 +16,7 @@ class Viewconnections extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
notice( t('Public access denied.') . EOL);
|
notice( t('Public access denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class Zotfeed extends \Zotlabs\Web\Controller {
|
|||||||
if(! $mindate)
|
if(! $mindate)
|
||||||
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
|
$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';
|
$result['message'] = 'Public access denied';
|
||||||
json_return_and_die($result);
|
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['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],array('mindate' => $mindate));
|
||||||
$result['success'] = true;
|
$result['success'] = true;
|
||||||
json_return_and_die($result);
|
json_return_and_die($result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
9
boot.php
9
boot.php
@ -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 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1567,7 +1567,7 @@ function get_online_status($nick) {
|
|||||||
|
|
||||||
$ret = array('result' => false);
|
$ret = array('result' => false);
|
||||||
|
|
||||||
if(get_config('system','block_public') && ! local_channel() && ! remote_channel())
|
if(observer_prohibited())
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
$r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1",
|
$r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1",
|
||||||
|
@ -402,7 +402,7 @@ function poco($a,$extended = false) {
|
|||||||
|
|
||||||
$system_mode = false;
|
$system_mode = false;
|
||||||
|
|
||||||
if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
|
if(observer_prohibited()) {
|
||||||
logger('mod_poco: block_public');
|
logger('mod_poco: block_public');
|
||||||
http_status_exit(401);
|
http_status_exit(401);
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ require_once('include/attach.php');
|
|||||||
|
|
||||||
function widget_profile($args) {
|
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);
|
return profile_sidebar(App::$profile, $block, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function widget_zcard($args) {
|
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);
|
$channel = channelx_by_n(App::$profile_uid);
|
||||||
return get_zcard($channel,get_observer_hash(),array('width' => 875));
|
return get_zcard($channel,get_observer_hash(),array('width' => 875));
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ function widget_fullprofile($arr) {
|
|||||||
if(! App::$profile['profile_uid'])
|
if(! App::$profile['profile_uid'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
|
$block = observer_prohibited();
|
||||||
|
|
||||||
return profile_sidebar(App::$profile, $block);
|
return profile_sidebar(App::$profile, $block);
|
||||||
}
|
}
|
||||||
@ -379,7 +379,7 @@ function widget_shortprofile($arr) {
|
|||||||
if(! App::$profile['profile_uid'])
|
if(! App::$profile['profile_uid'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false);
|
$block = observer_prohibited();
|
||||||
|
|
||||||
return profile_sidebar(App::$profile, $block, true, true);
|
return profile_sidebar(App::$profile, $block, true, true);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user