ok so after coding for a while here is what I have so far with some errors I'm going to ask about
public function deleteDir2($limitPath='', $path = '')
{
if($path == $limitPath && count(scandir($limitPath)) < 3) {
rmdir($limitPath);
return TRUE;
}
else {
if(!is_dir($limitPath)) {
$this->__errors[$limitPath] = $limitPath.' not a directory.';
return FALSE;
}
else {
if($path == '')
$path = $limitPath;
echo '<br/>'.$path.'<br/>';
//if(!is_writable($path)) {
//$this->__errors[$path] = $path.' Not writable.';
//return FALSE;
//}
//else {
$files = scandir($path);
print_r($files);
if(count($files) < 3) {
rmdir($path);
}
else {
foreach($files as $item) {
if($item == '.' || $item == '..') {
echo '<br/>continued';
continue;
}
elseif(is_file($item)) {
echo '<br/>Deleted '.$item;
unlink($item);
}
elseif(is_dir($item)) {
echo '<br/>'.$item.' is directory';
deleteDir2($limitPath, $path.'/'.$item);
}
}
echo '<br/>outside loop';
$pos = strpos($path, '/');
echo '<br/>'.$pos;
if($pos != (strlen($path)-1)) {
$oldPath = $path;
$newPath = '';
for($i=0; $i < ($pos); $i++){
$newPath .= $oldPath[$i];
echo '<br/>'.$newPath;
}
echo '<br/>'.$newPath;
}
$deleteDir2($limitPath, $newPath); // this is line 124
}
//}
}
}
}
here is my out put whe I run the script from the echo's that I placed in it for debugging.
photos/test
Array ( [0] => . [1] => .. [2] => untitled [3] => untitled.php [4] => untitled1.php [5] => untitled2.php )
continued
continued
outside loop
6
p
ph
pho
phot
photo
photos
photos
Fatal error: Function name must be a string in C:\wamp\www\main\phpGallery\class\filemanager.class.php on line 124
the problems that I am having is
[1] - In the foreach loop where I am checking for . and .. and then call continue I drop out of the loop
[2] - I'm inputing the new path into the function call and get an error asying that I am not passing in a string when clearly I am from teh out put
can someone help me or even tell me that me script works some what or is a complete disaster.
Thanks a lot.