do not poll for abandoned accounts

This commit is contained in:
Friendika 2011-09-29 21:20:19 -07:00
parent c1221cc052
commit 097c1f8da7
6 changed files with 26 additions and 4 deletions

View file

@ -10,7 +10,7 @@ require_once('include/nav.php');
define ( 'FRIENDIKA_PLATFORM', 'Free Friendika');
define ( 'FRIENDIKA_VERSION', '2.3.1119' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1092 );
define ( 'DB_UPDATE_VERSION', 1093 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View file

@ -424,7 +424,9 @@ CREATE TABLE IF NOT EXISTS `user` (
`deny_gid` mediumtext NOT NULL,
`openidserver` text NOT NULL,
PRIMARY KEY (`uid`),
KEY `nickname` (`nickname`)
KEY `nickname` (`nickname`),
KEY `account_expired` (`account_expired`),
KEY `login_date` (`login_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View file

@ -44,6 +44,12 @@ function poller_run($argv, $argc){
AND `account_expires_on` != '0000-00-00 00:00:00'
AND `account_expires_on` < UTC_TIMESTAMP() ");
$abandon_days = intval(get_config('system','account_abandon_days'));
if($abandon_days < 1)
$abandon_days = 0;
// once daily run expire in background
$d1 = get_config('system','last_expire_day');
@ -92,12 +98,17 @@ function poller_run($argv, $argc){
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
$abandon_sql = (($abandon_days)
? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days))
: ''
);
$contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND `network` != '%s'
$sql_extra
AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
AND `user`.`account_expired` = 0 ORDER BY RAND()",
AND `user`.`account_expired` = 0 $abandon_sql ORDER BY RAND()",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
dbesc(NETWORK_DIASPORA)

View file

@ -177,6 +177,8 @@ function admin_page_site_post(&$a){
$register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
$allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
@ -215,6 +217,7 @@ function admin_page_site_post(&$a){
set_config('system','maximagesize', $maximagesize);
set_config('config','register_policy', $register_policy);
set_config('system','account_abandon_days', $abandon_days);
set_config('config','register_text', $register_text);
set_config('system','allowed_sites', $allowed_sites);
set_config('system','allowed_email', $allowed_email);
@ -314,6 +317,7 @@ function admin_page_site(&$a) {
'$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
'$register_text' => array('register_text', t("Register text"), htmlentities($a->config['register_text'], ENT_QUOTES), "Will be displayed prominently on the registration page."),
'$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')),
'$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), "Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains"),
'$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), "Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains"),
'$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), "Check to block public access to all otherwise public personal pages on this site unless you are currently logged in."),

View file

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1092 );
define( 'UPDATE_VERSION' , 1093 );
/**
*
@ -770,3 +770,7 @@ function update_1091() {
}
function update_1092() {
q("ALTER TABLE `user` ADD INDEX ( `login_date` ) ");
q("ALTER TABLE `user` ADD INDEX ( `account_expired` ) ");
}

View file

@ -43,6 +43,7 @@
{{ inc field_input.tpl with $field=$proxy }}{{ endinc }}
{{ inc field_input.tpl with $field=$proxyuser }}{{ endinc }}
{{ inc field_input.tpl with $field=$timeout }}{{ endinc }}
{{ inc field_input.tpl with $field=$abandon_days }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>