]> git.mxchange.org Git - friendica.git/commitdiff
do not poll for abandoned accounts
authorFriendika <info@friendika.com>
Fri, 30 Sep 2011 04:20:19 +0000 (21:20 -0700)
committerFriendika <info@friendika.com>
Fri, 30 Sep 2011 04:20:19 +0000 (21:20 -0700)
boot.php
database.sql
include/poller.php
mod/admin.php
update.php
view/admin_site.tpl

index e8f2b6f0c06c340de34010500bbebfb2519e6549..85b571c828392b6a7ce2868c062d7759f7b23055 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -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' );
index 08d02d67e68f10eb1b6cbf6bd5964b1ac44773a2..f39728a33916c1463fc2e8b8ddf9d521180f253c 100644 (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;
 
 
index 07076508ff4b233005ccc32d6c27ac96cc04fb88..89a3408ec90efcf04deca6aa7f5e1dd00afecee2 100644 (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)
index da561d554b098383eabf790728ecf967f6f2ba4d..ebef1ccb9378b784d86107789fc33f4ca218cfc6 100644 (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."),
index 2f9277dae652311e96423470b03b2d966dae3052..0dd599e8396534cd5d8369baa89a7090692859a7 100644 (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` ) ");
+}
\ No newline at end of file
index 061656df760c8d558fa1c90ba40227785b92d2f0..9a122984546080450117655176e396a4623db839 100644 (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>