add site_dead flag to prevent delivery to dead sites. Allow sys channel webpages to be viewed even if site is configured "block public".

This commit is contained in:
redmatrix 2015-06-08 16:55:17 -07:00
parent 5b482c1daf
commit 39f0e6fe62
8 changed files with 52 additions and 18 deletions

View File

@ -49,7 +49,7 @@ define ( 'PLATFORM_NAME', 'redmatrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1142 );
define ( 'DB_UPDATE_VERSION', 1143 );
/**
* @brief Constant with a HTML line break.

View File

@ -30,16 +30,25 @@ function deliver_run($argv, $argc) {
if($h) {
$base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
if($base !== z_root()) {
$y = q("select site_update from site where site_url = '%s' ",
$y = q("select site_update, site_dead from site where site_url = '%s' ",
dbesc($base)
);
if($y && $y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) {
q("update outq set outq_priority = %d where outq_hash = '%s'",
intval($r[0]['outq_priority'] + 10),
dbesc($r[0]['outq_hash'])
);
logger('immediate delivery deferred for site ' . $base);
continue;
if($y) {
if(intval($y[0]['site_dead'])) {
q("delete from outq where outq_posturl = '%s'",
dbesc($r[0]['outq_posturl'])
);
logger('dead site ignored ' . $base);
continue;
}
if($y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) {
q("update outq set outq_priority = %d where outq_hash = '%s'",
intval($r[0]['outq_priority'] + 10),
dbesc($r[0]['outq_hash'])
);
logger('immediate delivery deferred for site ' . $base);
continue;
}
}
}
}

View File

@ -1266,6 +1266,7 @@ CREATE TABLE IF NOT EXISTS `site` (
`site_location` char(255) NOT NULL DEFAULT '',
`site_realm` char(255) NOT NULL DEFAULT '',
`site_valid` smallint NOT NULL DEFAULT '0',
`site_dead` smallint NOT NULL DEFAULT '0',
PRIMARY KEY (`site_url`),
KEY `site_flags` (`site_flags`),
KEY `site_update` (`site_update`),
@ -1275,7 +1276,8 @@ CREATE TABLE IF NOT EXISTS `site` (
KEY `site_sellpage` (`site_sellpage`),
KEY `site_pull` (`site_pull`),
KEY `site_realm` (`site_realm`),
KEY `site_valid` (`site_valid`)
KEY `site_valid` (`site_valid`),
KEY `site_dead` (`site_dead`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------

View File

@ -969,6 +969,7 @@ CREATE TABLE "site" (
"site_location" text NOT NULL DEFAULT '',
"site_realm" text NOT NULL DEFAULT '',
"site_valid" smallint NOT NULL DEFAULT '0',
"site_dead" smallint NOT NULL DEFAULT '0',
PRIMARY KEY ("site_url")
);
create index "site_flags" on site ("site_flags");
@ -979,6 +980,7 @@ create index "site_access" on site ("site_access");
create index "site_sellpage" on site ("site_sellpage");
create index "site_realm" on site ("site_realm");
create index "site_valid" on site ("site_valid");
create index "site_dead" on site ("site_dead");
CREATE TABLE "source" (
"src_id" serial NOT NULL,

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1142 );
define( 'UPDATE_VERSION' , 1143 );
/**
*
@ -1645,4 +1645,15 @@ function update_r1141() {
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1142() {
$r1 = q("alter table site add site_dead smallint not null default '0' ");
$r2 = q("create index site_dead on site ( site_dead ) ");
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View File

@ -11,10 +11,11 @@ function page_init(&$a) {
$profile = 0;
profile_load($a,$which,$profile);
if($a->profile['profile_uid'])
head_set_icon($a->profile['thumb']);
// load the item here in the init function because we need to extract
// the page layout and initialise the correct theme.
@ -22,9 +23,11 @@ function page_init(&$a) {
$observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
$perms = get_all_perms($a->profile['profile_uid'],$ob_hash);
if(! $perms['view_pages']) {
// perm_is_allowed is denied unconditionally when 'site blocked to unauthenticated members'.
// This bypasses that restriction for sys channel (public) content
if((! perm_is_allowed($a->profile['profile_uid'],$ob_hash,'view_pages')) && (! is_sys_channel($a->profile['profile_uid']))) {
notice( t('Permission denied.') . EOL);
return;
}
@ -58,6 +61,8 @@ function page_init(&$a) {
require_once('include/security.php');
$sql_options = item_permissions_sql($u[0]['channel_id']);
dbg(1);
$r = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and (( service = 'WEBPAGE' and
item_restrict = %d ) or ( service = 'PDL' and item_restrict = %d )) $sql_options $revision limit 1",
@ -77,6 +82,8 @@ function page_init(&$a) {
dbesc($page_id),
intval(ITEM_WEBPAGE)
);
dbg(0);
if($x) {
// Yes, it's there. You just aren't allowed to see it.
notice( t('Permission denied.') . EOL);
@ -119,7 +126,7 @@ function page_content(&$a) {
return;
if($r[0]['item_restrict'] == ITEM_PDL) {
$r[0]['body'] = t('Ipsum Lorem');
$r[0]['body'] = t('Lorem Ipsum');
$r[0]['mimetype'] = 'text/plain';
$r[0]['title'] = '';

View File

@ -60,17 +60,20 @@ function public_content(&$a, $update = 0, $load = false) {
}
require_once('include/identity.php');
require_once('include/security.php');
if(get_config('system','site_firehose')) {
require_once('include/security.php');
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
}
else {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$sql_extra = item_permissions_sql($sys['channel_id']);
$a->data['firehose'] = intval($sys['channel_id']);
}
$page_mode = 'list';
$simple_update = (($update) ? " and item.item_unseen = 1 " : '');

View File

@ -1 +1 @@
2015-06-07.1056
2015-06-08.1057