From: Mikael Nordfeldth Date: Thu, 11 Feb 2016 21:19:56 +0000 (+0100) Subject: Delete orphan files maintenance script X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=38a187b93ebe1069f105ccd7570b7bb6ab38fc50;p=quix0rs-gnu-social.git Delete orphan files maintenance script When deleting a profile it'll delete its notices and the coupling to file entries, but not the file entries themselves (and thus not the files). So if one to delete a person uploading offending images, then the images are left behind and can be hotlinked. This will remove it. --- diff --git a/scripts/delete_orphan_files.php b/scripts/delete_orphan_files.php new file mode 100755 index 0000000000..ad575187bd --- /dev/null +++ b/scripts/delete_orphan_files.php @@ -0,0 +1,66 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'y'; +$longoptions = array('yes'); + +$helptext = <<query($sql) !== false) { + print " Deleting {$file->N} entries: "; + while ($file->fetch()) { + try { + $file->getPath(); + $file->delete(); + print 'x'; + } catch (Exception $e) { + // either FileNotFound exception or ClientException + $file->delete(); + print '.'; + } + } +} +print "\nDONE.\n";