2013-02-26 01:09:40 +00:00
|
|
|
<?php /** @file */
|
2011-03-16 00:31:49 +00:00
|
|
|
|
2012-10-24 00:14:50 +00:00
|
|
|
require_once('boot.php');
|
|
|
|
require_once('include/cli_startup.php');
|
2011-03-16 00:31:49 +00:00
|
|
|
|
|
|
|
function expire_run($argv, $argc){
|
|
|
|
|
2012-10-24 00:14:50 +00:00
|
|
|
cli_startup();
|
2011-03-16 00:31:49 +00:00
|
|
|
|
2014-03-28 03:28:48 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 02:02:08 +00:00
|
|
|
// physically remove anything that has been deleted for more than two months
|
2012-01-30 23:13:24 +00:00
|
|
|
|
2014-03-28 03:28:48 +00:00
|
|
|
$r = q("delete from item where ( item_restrict & %d ) and changed < UTC_TIMESTAMP() - INTERVAL 36 DAY",
|
|
|
|
intval(ITEM_PENDING_REMOVE)
|
2012-10-24 00:14:50 +00:00
|
|
|
);
|
2012-05-08 22:33:01 +00:00
|
|
|
|
|
|
|
// make this optional as it could have a performance impact on large sites
|
|
|
|
|
|
|
|
if(intval(get_config('system','optimize_items')))
|
|
|
|
q("optimize table item");
|
2012-01-30 23:13:24 +00:00
|
|
|
|
2012-10-24 00:14:50 +00:00
|
|
|
logger('expire: start', LOGGER_DEBUG);
|
2011-03-16 00:31:49 +00:00
|
|
|
|
2012-10-24 00:14:50 +00:00
|
|
|
|
|
|
|
$r = q("SELECT channel_id, channel_address, channel_expire_days from channel where channel_expire_days != 0");
|
|
|
|
if($r && count($r)) {
|
2011-03-16 00:31:49 +00:00
|
|
|
foreach($r as $rr) {
|
2012-10-24 00:14:50 +00:00
|
|
|
logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $rr['channel_expire_days'], LOGGER_DEBUG);
|
|
|
|
item_expire($rr['channel_id'],$rr['channel_expire_days']);
|
2011-03-16 00:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-27 23:40:10 +00:00
|
|
|
|
2014-03-27 01:45:01 +00:00
|
|
|
$x = get_sys_channel();
|
2014-03-27 23:40:10 +00:00
|
|
|
if($x) {
|
|
|
|
|
|
|
|
// this should probably just fetch the channel_expire_days from the sys channel,
|
|
|
|
// but there's no convenient way to set it.
|
2014-03-27 01:45:01 +00:00
|
|
|
|
2014-03-27 23:40:10 +00:00
|
|
|
$expire_days = get_config('externals','expire_days');
|
|
|
|
if($expire_days === false)
|
|
|
|
$expire_days = 30;
|
|
|
|
if($expire_days)
|
|
|
|
item_expire($x['channel_id'],$expire_days);
|
|
|
|
}
|
2014-03-28 03:28:48 +00:00
|
|
|
|
|
|
|
|
2011-03-16 00:31:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_search(__file__,get_included_files())===0){
|
|
|
|
expire_run($argv,$argc);
|
|
|
|
killme();
|
|
|
|
}
|