$p) {
$j = 0;
$output = @shell_exec('rgrep '.$i.' main/');
$outputs = explode('\n', $output);
foreach ($outputs as $line) {
if (substr($line, 0, 5)=='rgrep') {
//this means a permission error, ignore
} else {
$j++;
}
}
if ($j === 0) {
$unused[$i] = $p;
}
}
echo '
';
/*
if (count($unexisting_img)<1) { die("No missing image
\n"); } else { echo "The following images were nowhere to be found:
\n"; }
foreach ($unexisting_img as $term => $file) {
echo "$term | in $file |
\n";
}
*/
echo 'Existing images('.count($found_img).'), unused('.count($unused).') |
'."\n";
echo 'Image file | Used x times |
'."\n";
$r = ksort($found_img);
foreach ($unused as $term => $path) {
if (isset($unused[$term])) {
echo '';
echo ''.$term.' | ';
echo ''.($path=='/'?'/':$path.'/').$term.' | ';
echo '
'."\n";
} else {
echo '';
echo ''.$term.' | ';
echo ''.($path=='/'?'/':$path.'/').$term.' | ';
echo '
'."\n";
}
}
echo "
\n";
/**
* Get the list of available images
* @param string $path The path to start the scan from
* @return array The files list
*/
function get_img_files($path)
{
$files = array();
//We know there are max 3 levels, so don't bother going recursive
$list = scandir($path);
foreach ($list as $entry) {
if (substr($entry, 0, 1)=='.') {
continue;
}
if (is_dir($path.$entry)) {
$sublist = scandir($path.$entry);
foreach ($sublist as $subentry) {
if (substr($subentry, 0, 1)=='.') {
continue;
}
if (is_dir($path.$entry.'/'.$subentry)) {
$subsublist = scandir($path.$entry.'/'.$subentry);
foreach ($subsublist as $subsubentry) {
if (substr($subsubentry, 0, 1)=='.') {
continue;
}
if (is_file($path.$entry.'/'.$subentry.'/'.$subsubentry)) {
$files[$subsubentry] = '/'.$entry.'/'.$subentry;
}
}
} elseif (is_file($path.$entry.'/'.$subentry)) {
$files[$subentry] = '/'.$entry;
}
}
} elseif (is_file($path.$entry)) {
$files[$entry] = '/';
}
}
return $files;
}