This script will clean your phpGraphy MySQL database from erronous entries.
It will check for the existance of files in your root_dir which is actually set to: Be sure to have a valid BACKUP of your database before you continue.
To launch the process, click here.
Checking that your \$config['pictures_dir']($config['pictures_dir']) does exists... [";
if (is_dir($config['pictures_dir'])) {
echo "OK]";
} else {
echo "FAILED]";
die;
}
echo "Checking table $sTableRatings...
";
$cmd="select * from $sTableRatings";
$res=mysql_db_query($sDB,$cmd,$nConnection);
while($row=mysql_fetch_array($res)) {
$filename=$config['pictures_dir'].$row["pic_name"];
if (!is_file($filename)) {
echo "Removing entry '$filename' [";
$cmd="DELETE FROM $sTableRatings WHERE pic_name = '".$row["pic_name"]."'";
if (@mysql_db_query($sDB,$cmd,$nConnection)) echo "OK"; else echo "FAILED";
echo "]
";
}
}
echo "Checking table $sTableComments...
";
$cmd="select * from $sTableComments";
$res=mysql_db_query($sDB,$cmd,$nConnection);
while($row=mysql_fetch_array($res)) {
$filename=$config['pictures_dir'].$row["pic_name"];
if (!is_file($filename)) {
echo "Removing entry '$filename' [";
$cmd="DELETE FROM $sTableComments WHERE pic_name = '".$row["pic_name"]."'";
if (@mysql_db_query($sDB,$cmd,$nConnection)) echo "OK"; else echo "FAILED";
echo "]
";
}
}
echo "Checking table $sTable...
";
$cmd="select * from $sTable";
$res=mysql_db_query($sDB,$cmd,$nConnection);
while($row=mysql_fetch_array($res)) {
$filename=$config['pictures_dir'].$row["name"];
if (!is_file($filename)) {
echo "Removing entry '$filename' [";
$cmd="DELETE FROM $sTable WHERE name = '".$row["name"]."'";
if (@mysql_db_query($sDB,$cmd,$nConnection)) echo "OK"; else echo "FAILED";
echo "]
";
}
}
echo "Done.\n"; flush();
?>