Hi,
Working on a small script that will read in a file containing filenames, and check if the filename is to be deleted or not. My in_array() function only seems to work on the last entry in the earray. Here is the code ..
When a file is matched from the array $files, it is expected to find an entry, but it only finds the last one ??PHP Code:<?php
$files = array(
'403.php',
'404.php',
'406.php',
'414.php',
'500.php',
'501.php',
'favicon.ico',
'.htaccess',
'robots.txt');
print_r($files);
$handle = @fopen('WP_ro_files.txt', "r");
if ($handle) {
while (!feof($handle)) {
$filenames[] = fgets($handle, 4096);
}
fclose($handle);
}
//print_r($filenames);
foreach ($filenames as $filename) {
$delete_ok = 1;
if (in_array($filename, $files)) {
echo "Filename found - $filename\n";
$delete_ok = 0;
} else {
$pieces = explode("/", $filename);
$result = count($pieces);
$path = $pieces[1]; //get the second element, which is the path or filename
if ($path == "plugins"){ //no files to be deleted in the plugins path
$delete_ok = 0;
}
if ($path == "themes"){ //no files to be deleted in the themes path
$delete_ok = 0;
}
}
if ($delete_ok){
echo "File to be deleted - $filename\n";
//put code here yo unlink the file (path name + filename)
} else {
echo "File will not be deleted - $filename\n";
}
}
?>
J

