I installed Drupal 6.8 on a remote server ( Apache/2.2.3 (Debian) PHP/5.2.0 ) in a /Drupal subfolder then tried to uninstall it.

I could delete all Drupal files and folders except this

/Drupal/sites/default/files/

When tried to change the files folder's CHMOD through an FTP client I got this warning

'500 Unknown command
Server does not support attribute modifications'

I tried to run this PHP code

<?php
`chmod -R a+w sites/default/files`;
?>

and got this warning

Warning: shell_exec() has been disabled for security reasons in /server_dirs/www_dirs/domainname/www/www.domainname.com/html/Drupal/fix0.php on line 2

Also ran fix.php found here
http://drupal.org/node/34028 which did change the folder's CHMOD to 777 but I still cannot delete it.

Should I ask the host to remove it or is there another solution?

Thanks

Comments

-Anti-’s picture

You might have done this already, but check the chmod of the 'default' directory itself. Drupal should set it to 555 after installation and on every cron run. If it is, then this is the reason you can't delete it or anything within it. Once you change 'default' (and all its subfolders/files) to 755, you should be able to delete them all.

Also note that many, many servers are setup to reject 777 chmod. If they are setup that way, then you have to use 755 instead. If the host disallows 777 they should then be using a program that recognises scripts which need 777 to function, and allows them to work using the safer 755 chmod. (It's called 'sysexec' or something like that).

stardate’s picture

If I try to change the files folder's CHMOD
to 755 - or anything for that matter - ,through my FTP client, I receive a warning.

'Server does not support attribute modifications'

I can change the default folder's CHMOD but not the files folder's.

I ran this script within /Drupal/sites/

and got this response

Made writable: /server_dirs/www_dirs/termekkereso/www/www.domainname.com/html/Drupal/sites/default/files

And in fact the files folder's CHMOD changed to 777. I couldn't achieved this through FTP.
I'm a PHP newbie but I guess with some modification this script could be used to change the CHMOD to 755?
Am I wrong?

<?php
file_fix_directory(dirname(__FILE__));

function file_fix_directory($dir, $nomask = array('.', '..', 'CVS')) {
  if (is_dir($dir)) {
     // Try to make each directory world writable.
     if (@chmod($dir, 0777)) {
       echo "<p>Made writable: " . $dir . "</p>";
     }
  }
  if (is_dir($dir) && $handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
      if (!in_array($file, $nomask) && $file[0] != '.') {
        if (is_dir("$dir/$file")) {
          // Recurse into subdirectories
          file_fix_directory("$dir/$file", $nomask);
        }
        else {
          $filename = "$dir/$file";
            // Try to make each file world writable.
            if (@chmod($filename, 0666)) {
              echo "<p>Made writable: " . $filename . "</p>";
            }
        }
      }
    }

    closedir($handle);
  }

}
?>
stardate’s picture

There was no need for that script.

I used this one

<?php

chmod("/server_dirs/www_dirs/username/www/www.domainname.com/html/Drupal/sites/default/files/", 0755);
?>

and it changed the files folder's CHMOD to 755.

Now I have default and files with 755.

The bad news is that I still can't delete this damn folder. :(

-Anti-’s picture

Have you got any sort of htaccess files in the files folder?
Maybe some sort of protection against getting files hacked is preventing you from modifying the directory?

But to be honest, it looks to me like it might be a host set-up or configuration problem.
Maybe you've got some unknown script reigning in your power for the sake of server security?

stardate’s picture

But I couldn't see it since my FTP client was not configured to show hidden files.

I suppose this was the cause although I didn't solve the problem by getting rid of .htaccess through FTP.

Rather I ran these two codes in the default folder. The first deleted whatever was in the files folder the second deleted the folder itself. Since rmdir() doesn't work if the folder is not empty there must have been something over there. :)

<?PHP 

/** 
* Empty folder (work recursuvely) 
* 
* @autor Hatem <http://hatem.phpmagazine.net> 
* @param string        $folder        Folder name (without trailing slash) 
* @param boolean    $debug        print debug message 
* @return void 
*/ 
function empty_folder($folder, $debug = false){ 
    
    if ($debug) { 
        echo "Cleaning folder $folder ... <br>"; 
    } 
    
    $d = dir($folder); 
    
    while (false !== ($entry = $d->read())) { 
    
        $isdir = is_dir($folder."/".$entry); 
        
        if (!$isdir and $entry!="." and $entry!="..") { 
        
            unlink($folder."/".$entry); 
            
        } elseif ($isdir  and $entry!="." and $entry!="..") { 
        
            empty_folder($folder."/".$entry,$debug); 
            
            rmdir($folder."/".$entry); 
            
        } 
    } 
    $d->close(); 
} 
empty_folder("files",true); 
?>
<?php
if (!is_dir('files')) {
    mkdir('files');
}

rmdir('files');
?>

Don't you know how .htaccess ends up in the files folder?
It's not there after a normal install.

Somered’s picture

Try using this sctrip. Create 1.php and 2.php. Put them in the folder that contains the folder you want to delete.
In the last row of the files instead of "hello" type your the name of the folder you want to delete.
Run the first file and then run the second one. Don't worry if it shows errors. At this point you shouldn't find the folder but even if you do I think you should be able to delete it.

//----------------------------first file (1.php)-----------------------------------------

   function rchmod($parent, $dmod, $fmod) {
         if (is_dir($parent)) {
                 $old = umask(0000);
                 chmod($parent, $dmod);
                 umask($old);
                 if ($handle = opendir($parent)) {
                         while (($file = readdir($handle)) !== false) {
                           if ($file === "." or $file === "..") {
                                         continue;
                                 } elseif (is_dir($parent . '/' . $file)) {
                     rchmod($parent . '/' . $file, $dmod, $fmod);
                                 } else {
                                         $old = umask(0000);
                                         chmod($parent . '/' . $file, $fmod);
                                     umask($old);
                                 }
                         }
                         closedir($handle);
            }
         } else {
                 $old = umask(0000);
                 chmod($parent, $fmod);
                 umask($old);
         }
    }
    rchmod('hello', 0777, 0666);

//----------------------------------------------------------------

//--------------------Second file (2.php)--------------------------

<?
function effacer($dir)
{
if ($handle = opendir($dir))
{
while (($file = readdir($handle)) !== false)
{
if ($file === "." or $file === "..")
{
continue;
}
elseif (is_dir($dir . '/' . $file))
{
effacer($dir . '/' . $file);
}
else
{
unlink($dir . '/' . $file);
}
}
closedir($handle);
}
rmdir($dir);
}

effacer('hello'); ?>

//----------------------------------------------------------------

www.somered.com
www.somered.com/sstorage