FreePgs.com Forum
December 07, 2021, 02:11:57 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Donate to FreePgs.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Files Won't Delete?  (Read 3784 times)
Ben
FreePgs Tech Support
Technical Support
Sr. Member
*****

Karma: +12/-0
Offline Offline

Posts: 344

Blog entries (0)

View Profile WWW
« on: November 10, 2007, 02: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)
Code:
<?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.
« Last Edit: November 10, 2007, 02:35:04 PM by Ben » Logged

bonehead
Verified Account
Full Member
*

Karma: +4/-2
Offline Offline

Posts: 178

Blog entries (0)

View Profile WWW
« Reply #1 on: November 10, 2007, 09:03:27 PM »

Nice, but maybe fix the file permission errors on freepgs side?
Logged
FreePgs.com Forum
« Reply #1 on: November 10, 2007, 09:03:27 PM »

 Logged
Ben
FreePgs Tech Support
Technical Support
Sr. Member
*****

Karma: +12/-0
Offline Offline

Posts: 344

Blog entries (0)

View Profile WWW
« Reply #2 on: November 11, 2007, 02: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.
Logged

brainiac744
Verified Account
Sr. Member
*

Karma: +10/-0
Offline Offline

Posts: 403

Blog entries (0)

View Profile
« Reply #3 on: November 12, 2007, 08:15:52 AM »

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"
Logged
FreePgs.com Forum
« Reply #3 on: November 12, 2007, 08:15:52 AM »

 Logged
bonehead
Verified Account
Full Member
*

Karma: +4/-2
Offline Offline

Posts: 178

Blog entries (0)

View Profile WWW
« Reply #4 on: November 12, 2007, 11:49:27 PM »

What? if you give someone your password then you deserve it. Else allow account owner all permission rights over files.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!