Here is a very simple, very dirty, script that will go through, check all the images in your DB and see if th efile is there. If not, then it will delete the row from the DB and delete the thumbnail.
There is no auth checking at all. I actually cut and pasted a lot of this from the admin/users.php file.
No warranties. If it melts your computer and renders you sterile, not my fault.
<?php
define('IN_CP', 1);
define('ROOT_PATH', './../');
require('admin_global.php');
// Delete Images ---------------------------------------------------------------------
$sql = "SELECT image_id, cat_id, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
order by image_id";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
if (!file_exists(MEDIA_PATH."/".$row['cat_id']."/".$row['image_media_file'])) {
$sql = "DELETE FROM ".IMAGES_TABLE."
WHERE image_id = ".$row['image_id'];
if (file_exists(THUMB_PATH."/".$row['cat_id']."/".$row['image_thumb_file']) && !empty($row['image_thumb_file'])) {
unlink(THUMB_PATH."/".$row['cat_id']."/".$row['image_thumb_file']);
}
echo $row['image_media_file']." does not exist.<BR>";
echo " ".$lang['images_delete_success']."<br />\n";
$del_images = $site_db->query($sql);
}
}
echo "Script Finished."
?>