public function is_directory_removable($fullpath) {

        if (!is_writable($fullpath)) {
            return false;
        }

        if (is_dir($fullpath)) {
            $handle = opendir($fullpath);
        } else {
            return false;
        }

        $result = true;

        while ($filename = readdir($handle)) {

            if ($filename === '.' or $filename === '..') {
                continue;
            }

            $subfilepath = $fullpath.'/'.$filename;

            if (is_dir($subfilepath)) {
                $result = $result && $this->is_directory_removable($subfilepath);

            } else {
                $result = $result && is_writable($subfilepath);
            }
        }

        closedir($handle);

        return $result;
    }
public function is_directory_removable($fullpath) {

        if (!is_writable($fullpath)) {
            return false;
        }

        if (is_dir($fullpath)) {
            $handle = opendir($fullpath);
        } else {
            return false;
        }

        $result = true;

        while ($filename = readdir($handle)) {

            if ($filename === '.' or $filename === '..') {
                continue;
            }

            $subfilepath = $fullpath.'/'.$filename;

            if (is_dir($subfilepath)) {
                $result = $result && $this->is_directory_removable($subfilepath);

            } else {
                $result = $result && is_writable($subfilepath);
            }
        }

        closedir($handle);

        return $result;
    }
public function is_directory_removable ( $ fullpath ) { if ( ! is_writable ( $ fullpath ) ) { return false ; } if ( is_dir ( $ fullpath ) ) { $ handle = opendir ( $ fullpath ) ; } else { return false ; } $ result = true ; while ( $ filename = readdir ( $ handle ) ) { if ( $ filename === '.' or $ filename === '..' ) { continue ; } $ subfilepath = $ fullpath . '/' . $ filename ; if ( is_dir ( $ subfilepath ) ) { $ result = $ result && $ this -> is_directory_removable ( $ subfilepath ) ; } else { $ result = $ result && is_writable ( $ subfilepath ) ; } } closedir ( $ handle ) ; return $ result ; }
Check if the given directory can be removed by the web server process.

This recursively checks that the given directory and all its contents
it writable.

@param string $fullpath
@return boolean
Check if the given directory can be removed by the web server process .