示例#1
0
 public static function enqueueNewFeeds(array $args = array())
 {
     if (!isset($args['interval']) || !is_int($args['interval']) || $args['interval'] <= 0) {
         $args['interval'] = self::DEFAULT_INTERVAL;
     }
     $args['interval'] *= 60;
     // minutes to seconds
     $feedsub = new FeedSub();
     $feedsub->sub_state = 'nohub';
     // Find feeds that haven't been polled within the desired interval,
     // though perhaps we're abusing the "last_update" field here?
     $feedsub->whereAdd(sprintf('last_update < "%s"', common_sql_date(time() - $args['interval'])));
     $feedsub->find();
     $qm = QueueManager::get();
     while ($feedsub->fetch()) {
         $orig = clone $feedsub;
         $item = array('id' => $feedsub->id);
         $qm->enqueue($item, self::QUEUE_CHECK);
         $feedsub->last_update = common_sql_now();
         $feedsub->update($orig);
     }
 }
      Options:

    -d --dry-run look but don't mess with it


END_OF_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
$dry = false;
if (have_option('d') || have_option('dry-run')) {
    $dry = true;
}
echo "Looking for feed subscriptions with dirty no good huburis...\n";
$feedsub = new FeedSub();
$feedsub->sub_state = 'subscribe';
$feedsub->whereAdd('created < DATE_SUB(NOW(), INTERVAL 1 HOUR)');
$feedsub->find();
$cnt = 0;
while ($feedsub->fetch()) {
    echo "----------------------------------------------------------------------------------------\n";
    echo '           feed: ' . $feedsub->uri . "\n" . '        hub uri: ' . $feedsub->huburi . "\n" . ' subscribe date: ' . date('r', strtotime($feedsub->created)) . "\n";
    if (!$dry) {
        $feedsub->delete();
        echo "                 (DELETED)\n";
    } else {
        echo "                 (WOULD BE DELETED)\n";
    }
    echo "----------------------------------------------------------------------------------------\n";
    $cnt++;
}
if ($cnt == 0) {
示例#3
0
 public static function renewalCheck()
 {
     $fs = new FeedSub();
     // the "" empty string check is because we historically haven't saved unsubscribed feeds as NULL
     $fs->whereAdd('sub_end IS NOT NULL AND sub_end!="" AND sub_end < NOW() - INTERVAL 1 day');
     if (!$fs->find()) {
         // find can be both false and 0, depending on why nothing was found
         throw new NoResultException($fs);
     }
     return $fs;
 }