* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', dirname(__DIR__));
+define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
$shortoptions = 'y';
$longoptions = array('yes');
Will print '.' for each deleted File entry and 'x' if it also had a locally stored file.
+WARNING WARNING WARNING, this will also delete Qvitter files such as background etc. since
+they are not linked to notices (yet anyway).
+
END_OF_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
print "Finding File entries that are not related to a Notice (or the notice has been deleted)...";
$file = new File();
-$sql = 'SELECT file.id FROM file'.
- ' JOIN file_to_post ON file_to_post.file_id=file.id'.
+$sql = 'SELECT file.* FROM file'.
+ ' LEFT JOIN file_to_post ON file_to_post.file_id=file.id'.
' WHERE'.
' NOT EXISTS (SELECT file_to_post.file_id FROM file_to_post WHERE file.id=file_to_post.file_id)'.
- ' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=file_to_post.post_id);';
+ ' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=file_to_post.post_id)'.
+ ' GROUP BY file.id;';
if ($file->query($sql) !== false) {
print " {$file->N} found.\n";