public function chmodR($path, $filemode)
    {

        if (!$this->isFolder($path)) {
            return $this->chmod($path, $filemode);
        }

        $dirh = @opendir($path);
        while ($file = readdir($dirh)) {
            if ($file != '.' && $file != '..') {
                $fullpath = $path . '/' . $file;
                if (!$this->isFolder($fullpath)) {
                    if (!$this->chmod($fullpath, $filemode)) {
                        return false;
                    }
                } else {
                    if (!$this->chmodR($fullpath, $filemode)) {
                        return false;
                    }
                }
            }
        }

        closedir($dirh);

        if ($this->chmod($path, $filemode)) {
            return true;
        } else {
            return false;
        }
    }