Sto impazzendo!

Voglio estrarre da una cartella stabilita solo quei file o sottocartelle che abbiano una data antecedenta a quella di cut-off prestabilita.
Per fare questo ho creato lo script seguente:

codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<?php

$giorno = intval(strtotime('2002-06-30 12:00:00'));
echo "Data di cut-off: $giorno";
echo "
";
$listd = array();

if ($handle = opendir('.')) {
  while (false !== ($file = readdir($handle))) {
	if ($file != "." && $file != ".." && is_dir($file)) {
		array_push($listd, $file);
	}
  }
  closedir($handle);
}



foreach ($listd as $value) {
	recursedir($value);
}

function recursedir($BASEDIR) {
       $hndl=opendir($BASEDIR);
       while($file=readdir($hndl)) {
               if ($file=='.' || $file=='..') continue;
                       $completepath="$BASEDIR/$file";
							if (is_dir($completepath)) {
								   # its a dir, recurse.
//								   recursedir($BASEDIR.'/'.$file);
								   if (intval(filemtime($completepath)) < $giorno){
								   print "DIR; $BASEDIR/$file; ".filemtime($completepath)."
\n";
								   }
							} else {
								   # its a file.
								   if (intval(filemtime($completepath)) < $giorno){
								   print "FILE; $BASEDIR/$file; ".filemtime($completepath)."
\n";
								   }
							}
       }
}
?>
</body>
</html>
Ora provo a mettere questo file nella cartella che voglio analizzare ma... ma... mi restituisce o tutti i file o nessuno. Come faccio?
:master: