#!/usr/bin/env php . /** * StoreRemoteMediaPlugin * * @category Plugin * @package GNUsocial * @author Diogo Cordeiro * @copyright 2018 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ define('INSTALLDIR', dirname(__DIR__, 3)); define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); $shortoptions = 'l::a::i'; $longoptions = ['limit=', 'all', 'image']; $helptext = <<query(sprintf( <<<'END' SELECT file_to_post.file_id FROM file_to_post INNER JOIN file ON file_to_post.file_id = file.id INNER JOIN notice ON file_to_post.post_id = notice.id WHERE notice.is_local = 0 %1$s%2$sAND notice.modified <= '%3$s' GROUP BY file_to_post.file_id ORDER BY MAX(notice.modified) END, $image_only ? 'AND file.width IS NOT NULL AND file.height IS NOT NULL ' : '', $include_previews ? '' : 'AND file.filehash IS NOT NULL ', $fn->escape($max_date) )); while ($fn->fetch()) { $file = File::getByID($fn->file_id); $file_info_id = $file->getID(); // Delete current file $file->delete(); if (!$quiet) { echo "Deleted file with id: {$file_info_id}\n"; } }