Example #1
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Example #2
1
function expire_run($argv, $argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once 'include/session.php';
    require_once 'include/datetime.php';
    require_once 'library/simplepie/simplepie.inc';
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    load_config('config');
    load_config('system');
    $a->set_baseurl(get_config('system', 'url'));
    // physically remove anything that has been deleted for more than two months
    $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
    q("optimize table item");
    logger('expire: start');
    $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
            item_expire($rr['uid'], $rr['expire']);
        }
    }
    return;
}
Example #3
0
File: expire.php Project: Mauru/red
function expire_run($argv, $argc)
{
    cli_startup();
    $r = q("select id from item where (item_restrict & %d) and not (item_restrict & %d) and changed < UTC_TIMESTAMP() - INTERVAL 10 DAY", intval(ITEM_DELETED), intval(ITEM_PENDING_REMOVE));
    if ($r) {
        foreach ($r as $rr) {
            drop_item($rr['id'], false, DROPITEM_PHASE2);
        }
    }
    // physically remove anything that has been deleted for more than two months
    $r = q("delete from item where ( item_restrict & %d ) and changed < UTC_TIMESTAMP() - INTERVAL 36 DAY", intval(ITEM_PENDING_REMOVE));
    // make this optional as it could have a performance impact on large sites
    if (intval(get_config('system', 'optimize_items'))) {
        q("optimize table item");
    }
    logger('expire: start', LOGGER_DEBUG);
    $r = q("SELECT channel_id, channel_address, channel_expire_days from channel where channel_expire_days != 0");
    if ($r && count($r)) {
        foreach ($r as $rr) {
            logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $rr['channel_expire_days'], LOGGER_DEBUG);
            item_expire($rr['channel_id'], $rr['channel_expire_days']);
        }
    }
    $x = get_sys_channel();
    if ($x) {
        // this should probably just fetch the channel_expire_days from the sys channel,
        // but there's no convenient way to set it.
        $expire_days = get_config('externals', 'expire_days');
        if ($expire_days === false) {
            $expire_days = 30;
        }
        if ($expire_days) {
            item_expire($x['channel_id'], $expire_days);
        }
    }
    return;
}
Example #4
0
function twitter_expire($a, $b)
{
    $days = get_config('twitter', 'expire');
    if ($days == 0) {
        return;
    }
    $r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_TWITTER));
    require_once "include/items.php";
    logger('twitter_expire: expire_start');
    $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
    if (count($r)) {
        foreach ($r as $rr) {
            logger('twitter_expire: user ' . $rr['uid']);
            item_expire($rr['uid'], $days, NETWORK_TWITTER, true);
        }
    }
    logger('twitter_expire: expire_end');
}
Example #5
0
 public static function run($argc, $argv)
 {
     cli_startup();
     // perform final cleanup on previously delete items
     $r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('10 DAY'));
     if ($r) {
         foreach ($r as $rr) {
             drop_item($rr['id'], false, DROPITEM_PHASE2);
         }
     }
     // physically remove anything that has been deleted for more than two months
     /** @FIXME - this is a wretchedly inefficient query */
     $r = q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('36 DAY'));
     /** @FIXME make this optional as it could have a performance impact on large sites */
     if (intval(get_config('system', 'optimize_items'))) {
         q("optimize table item");
     }
     logger('expire: start', LOGGER_DEBUG);
     $site_expire = get_config('system', 'default_expire_days');
     logger('site_expire: ' . $site_expire);
     $r = q("SELECT channel_id, channel_system, channel_address, channel_expire_days from channel where true");
     if ($r) {
         foreach ($r as $rr) {
             // expire the sys channel separately
             if (intval($rr['channel_system'])) {
                 continue;
             }
             // service class default (if non-zero) over-rides the site default
             $service_class_expire = service_class_fetch($rr['channel_id'], 'expire_days');
             if (intval($service_class_expire)) {
                 $channel_expire = $service_class_expire;
             } else {
                 $channel_expire = $site_expire;
             }
             if (intval($channel_expire) && intval($channel_expire) < intval($rr['channel_expire_days']) || intval($rr['channel_expire_days'] == 0)) {
                 $expire_days = $channel_expire;
             } else {
                 $expire_days = $rr['channel_expire_days'];
             }
             // if the site or service class expiration is non-zero and less than person expiration, use that
             logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $expire_days, LOGGER_DEBUG);
             item_expire($rr['channel_id'], $expire_days);
         }
     }
     $x = get_sys_channel();
     if ($x) {
         // this should probably just fetch the channel_expire_days from the sys channel,
         // but there's no convenient way to set it.
         $expire_days = get_config('system', 'sys_expire_days');
         if ($expire_days === false) {
             $expire_days = 30;
         }
         if (intval($site_expire) && intval($site_expire) < intval($expire_days)) {
             $expire_days = $site_expire;
         }
         logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
         if ($expire_days) {
             item_expire($x['channel_id'], $expire_days);
         }
         logger('Expire: sys: done', LOGGER_DEBUG);
     }
 }