FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Ben on November 10, 2007, 07:25:49 PM

Title: Files Won't Delete?
Post by: Ben on November 10, 2007, 07:25:49 PM
Okay, with the massive amount of questions we've been getting on this, I figured it might as well be useful to make a topic about this.

Your files won't delete via FTP if they were created via PHP.  Your files also won't delete via PHP if they were created via FTP. To delete php files, you're best bet is to use the function below.

Taking code from the php manual (http://us.php.net/manual/en/function.rmdir.php#78687)
<?php
function RecursiveFolderDelete $folderPath ){
  if ( 
is_dir $folderPath ) ){
    foreach ( 
scandir $folderPath ) as $value ){
      if ( 
$value != "." && $value != ".." ){
        
$value $folderPath "/" $value;
        if ( 
is_dir $value ) ){
          
RecursiveFolderDelete $value );
        }elseif ( 
is_file $value ) ){
          @
unlink $value );
        }
      }
    }
    return 
rmdir $folderPath );
  }else{
    return 
FALSE;
  }

?>


Call this function on any sub-folder on your account, and anything left once this function is done should be able to be deleted via ftp.

If you still have problems after this, feel free to use the contact form and we'll help from there.
Title: Re: Files Won't Delete?
Post by: bonehead on November 11, 2007, 02:03:27 AM
Nice, but maybe fix the file permission errors on freepgs side?
Title: Re: Files Won't Delete?
Post by: Ben on November 11, 2007, 07:13:35 PM
Problem is with security. Say you have a file uploader that isn't validating files properly, and it allows you to upload a .php file. Someone uploads a file similar to that, and manages to delete all files on your entire site.


It's a never-ending battle between security and functionality.
Title: Re: Files Won't Delete?
Post by: brainiac744 on November 12, 2007, 01:15:52 PM
You could also set PHP to chmod the files to a less restrictive permission setting as you upload files if you wanted. This is hardly a freepgs "permission error"
Title: Re: Files Won't Delete?
Post by: bonehead on November 13, 2007, 04:49:27 AM
What? if you give someone your password then you deserve it. Else allow account owner all permission rights over files.