2012-01-28 06:12:54 +09:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2019-09-18 23:15:00 +09:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package GNUsocial
|
|
|
|
* @copyright 2010 StatusNet, Inc.
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2012-01-28 06:12:54 +09:00
|
|
|
*/
|
|
|
|
|
2019-09-18 23:15:00 +09:00
|
|
|
define('INSTALLDIR', dirname(__DIR__, 3));
|
|
|
|
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
2012-01-28 06:12:54 +09:00
|
|
|
|
2015-02-05 00:48:12 +09:00
|
|
|
$longoptions = array('delete-inactive');
|
|
|
|
$shortoptions = 'd';
|
|
|
|
|
2012-01-28 06:12:54 +09:00
|
|
|
$helptext = <<<END_OF_HELP
|
|
|
|
gcfeeds.php [options]
|
|
|
|
Clean up feeds that no longer have subscribers.
|
|
|
|
|
2015-02-05 00:48:12 +09:00
|
|
|
-d --delete-inactive Delete inactive feeds from feedsub table.
|
|
|
|
|
2012-01-28 06:12:54 +09:00
|
|
|
END_OF_HELP;
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
|
|
|
|
2015-02-05 00:48:12 +09:00
|
|
|
$delete_inactive = have_option('d', 'delete-inactive');
|
|
|
|
$delcount = 0;
|
|
|
|
|
2012-01-28 06:12:54 +09:00
|
|
|
$feedsub = new FeedSub();
|
2014-05-06 23:18:47 +09:00
|
|
|
$feedsub->find();
|
2012-01-28 06:12:54 +09:00
|
|
|
while ($feedsub->fetch()) {
|
2014-05-06 22:40:57 +09:00
|
|
|
try {
|
2014-05-20 00:58:05 +09:00
|
|
|
echo $feedsub->getUri() . " ({$feedsub->sub_state})";
|
2014-05-06 22:40:57 +09:00
|
|
|
if ($feedsub->garbageCollect()) {
|
2015-02-05 00:48:12 +09:00
|
|
|
if ($delete_inactive) {
|
|
|
|
$delcount++;
|
|
|
|
$feedsub->delete();
|
|
|
|
echo " DELETED";
|
|
|
|
}
|
2014-05-06 22:40:57 +09:00
|
|
|
echo " INACTIVE\n";
|
|
|
|
} else {
|
|
|
|
echo " ACTIVE\n";
|
|
|
|
}
|
2014-05-20 00:58:05 +09:00
|
|
|
} catch (NoProfileException $e) {
|
|
|
|
echo " DELETED (no profile)\n";
|
|
|
|
$feedsub->delete();
|
|
|
|
continue;
|
|
|
|
} catch (NoUriException $e) {
|
|
|
|
// Probably the getUri() call
|
|
|
|
echo "[unknown] DELETED (no uri)\n";
|
|
|
|
$feedsub->delete();
|
|
|
|
continue;
|
2014-05-06 22:40:57 +09:00
|
|
|
} catch (Exception $e) {
|
|
|
|
echo " ERROR: {$e->getMessage()}\n";
|
2012-01-28 06:12:54 +09:00
|
|
|
}
|
|
|
|
}
|
2015-02-05 00:48:12 +09:00
|
|
|
|
2019-09-18 23:15:00 +09:00
|
|
|
if ($delete_inactive) {
|
|
|
|
echo "\nDeleted $delcount inactive feeds.\n";
|
|
|
|
}
|